static public bool ListCars() { //Console.Clear(); for (int i = 0; i < carlot.Count; i++) { Console.WriteLine($"{i + 1}. {carlot[i]}"); } Console.WriteLine($"{carlot.Count + 1} Add a car"); Console.WriteLine($"{carlot.Count + 2} quit "); Console.WriteLine("which car would you like to buy?"); int choice = Int32.Parse(Console.ReadLine()); if (choice > 0 && choice < carlot.Count + 1) { Console.WriteLine($"you selected\n{ carlot[choice]}"); Console.WriteLine($"would you like to buy this car? y/n"); string buy = Console.ReadLine(); if (buy == "y") { Console.WriteLine("Execellent! our finance department will be in touch shortly. "); CarLot.BuyCar(choice, carlot); } else { Console.Clear(); } return(true); } else if (choice == carlot.Count + 1) { CarLot.UserAddedCar(); return(true); } else if (choice == carlot.Count + 2) { Console.WriteLine("Have a great day!"); return(false); } else { return(false); } }
static public void UserAddedCar() { Console.Write("Make: "); string make = Console.ReadLine(); Console.Write("Model: "); string model = Console.ReadLine(); Console.Write("Year: "); int year = Int32.Parse(Console.ReadLine()); Console.Write("Price: "); decimal price = Int32.Parse(Console.ReadLine()); Console.Write("Mileage: "); double mileage = Int32.Parse(Console.ReadLine()); CarLot.AddCar(new UsedCar(make, model, year, price, mileage)); }