//method to add a vroom public void addVroom(String inMake, String inModel, double inPrice, String inColor, double inSales, int inQty) { Vroom newVroom = new Vroom(inMake, inModel, inPrice, inColor, inSales, inQty); vrooms.Add(newVroom); logger.logAdd(newVroom); }
//gets the report of a specific vroom public String getSingleReport(String make, String model, String color) { String report = ""; Vroom vroom = getVroom(make, model, color); report = String.Format(("{0,-10}, {1,-10}({2}) \nTotal sales: R {3, 10}\n {4,5}\n\n"), vroom.make.ToString(), vroom.model, vroom.color.ToString(), vroom.sales, vroom.qty); return(report); }
private void btnSale_Click(object sender, RoutedEventArgs e) { //gets the index from the combo box and calls method to substract from the quantity of the chosen object int index = cmbVrooms.SelectedIndex; Vroom details = obj.getVroomDetails(index); obj.sellVroom(details.make, details.model, details.color); MessageBoxResult result = MessageBox.Show("Done"); }
public void logSale(Vroom vroom) { //method to record the sale of the object String entry = ""; StreamWriter sw = new StreamWriter("Log_File.txt", true); entry = "SALE - " + now.ToString() + " - Vroom sold by (username): " + vroom.model + " - " + vroom.make + " (" + vroom.color + ")"; sw.WriteLine(entry); sw.Close(); }
public void logAdd(Vroom vroom) { //method to record an addition to the list String entry = ""; StreamWriter sw = new StreamWriter("Log_File.txt", true); entry = "ADD - " + now.ToString() + " - Vroom added by (username): " + vroom.model + " - " + vroom.make + " (" + vroom.color + ")"; sw.WriteLine(entry); sw.Close(); }
//gets the details of the vroom in the list at the specific index provided public String getDetails(int index) { String details = ""; Vroom vroom = vrooms[index]; details = "FULL DETAILS:\n" + vroom.make + "\n" + vroom.model + " (" + vroom.color + ")\nPrice: R" + vroom.price; return(details); }
//decreases the quantity of the vroom by 1 when there is a sale public void sellVroom(String inMake, String inModel, String inColor) { Vroom old = getVroom(inMake, inModel, inColor); //updates the qty property of the vroom object to indicate that a vroom has been sold int qty = old.qty - 1; //takes the price that is the cost price in the vroom object and then adds a markup to be added to the sales value double salesVal = old.sales + (old.price * 1.5); Vroom newVroom = new Vroom(old.make, old.model, old.price, old.color, salesVal, qty); vrooms.Remove(old); vrooms.Add(newVroom); logger.logSale(newVroom); }
public Vroom getVroomDetails(int index) { Vroom details = vrooms[index]; return(details); }
//gets the specific 'vroom' based on the model, make color public Vroom getVroom(String make, String model, String color) { Vroom old = vrooms.Where(v => v.model.Equals(model) && v.make.Equals(make) && v.color.Equals(color)).First(); return(old); }