/// <summary> /// Generates the random car item. /// </summary> /// <returns>The random car item.</returns> public CarItem GenerateRandomCarItem() { string name = GenerateRandomName(); int code = GenerateRandomeCode(); double price = GenerateRandomPrice(); int quantity = GenerateRandomQuantity(); double discount = GenerateRandomDiscount(); CarItem randomCarItem = new CarItem(name, code, price, quantity); randomCarItem.SetDiscount(discount); return(randomCarItem); }
/// <summary> /// Loads the databes from a csv file. /// </summary> /// <param name="path">Path.</param> public void LoadDatabaseFromCSV(string path) { using (StreamReader stream = new StreamReader(path)) { CsvReader csvReader = new CsvReader(stream); csvReader.Read(); while (csvReader.Read()) { long barcode = Convert.ToInt64(csvReader.GetField(0)); string name = csvReader.GetField(1); int quanitity = Convert.ToInt32(csvReader.GetField(2)); double price = Convert.ToDouble(csvReader.GetField(3)); double discount = Convert.ToDouble(csvReader.GetField(4)); CarItem carItem = new CarItem(name, barcode, price, quanitity); carItem.SetDiscount(discount); database.Add(barcode, carItem); barcodes.Add(barcode); } } }