public override Car makeCar(Car thatCar) { usedCar thisCar = thatCar as usedCar; Console.WriteLine("Enter the make of the car: "); thisCar.make = Console.ReadLine(); Console.WriteLine("Enter the model of the car: "); thisCar.model = Console.ReadLine(); Console.WriteLine("Enter the year of the car: "); thisCar.year = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter the mileage of the car: "); thisCar.mileage = Convert.ToInt32(Console.ReadLine()); return(thisCar); }
static void addCar(List <Car> carList) { string choice; do { Console.WriteLine("Would you like to add a new or used car?"); choice = Console.ReadLine(); newCar thatCar = new newCar(); usedCar thisCar = new usedCar(); if (choice == "new") { thatCar.makeCar(thatCar); carList.Add(thatCar); } if (choice == "used") { thisCar.makeCar(thisCar); carList.Add(thisCar); } } while (choice != "no"); }