Beispiel #1
0
        public void AddCar(List <Car> carinventory)
        {
            Console.Write("Would you like to add a new or used car to the invetory? new- enter N / used - enter U: ");
            string addauto = Console.ReadLine().ToLower();

            if (addauto == "n")
            {
                Car newCar = new Car();
                Console.Write("Enter the Make of the car: ");
                newCar.Make = Console.ReadLine();
                Console.Write("Enter the Model of the car: ");
                newCar.Model = Console.ReadLine();
                Console.Write("Enter the Year of the car: ");
                newCar.Year = Int32.Parse(Console.ReadLine());
                Console.Write("Enter the List Price of the car: ");
                newCar.Price = Double.Parse(Console.ReadLine());
                Console.Write("Enter the ID number of the car: ");
                newCar.Id = Int32.Parse(Console.ReadLine());
                carinventory.Add(newCar);
                Console.WriteLine(newCar.ToString());
            }
            else
            {
                UsedCar tradeIn = new UsedCar();
                Console.Write("Enter the Make of the car: ");
                tradeIn.Make = Console.ReadLine();
                Console.Write("Enter the Model of the car: ");
                tradeIn.Model = Console.ReadLine();
                Console.Write("Enter the Year of the car: ");
                tradeIn.Year = Int32.Parse(Console.ReadLine());
                Console.Write("Enter the List Price of the car: ");
                tradeIn.Price = Double.Parse(Console.ReadLine());
                Console.Write("Enter the Mileage of the car: ");
                tradeIn.Mileage = double.Parse(Console.ReadLine());
                Console.Write("Enter the ID number of the car");
                tradeIn.Id = Int32.Parse(Console.ReadLine());


                carinventory.Add(tradeIn);
                Console.WriteLine(tradeIn.ToString());
            }
        }
Beispiel #2
0
        static void SellCar(List <Car> carinventory) //allows customer to sell car and adds to inventory
        {
            UsedCar tradeIn = new UsedCar();

            Console.Write("Enter the Make of the car: ");
            tradeIn.Make = Console.ReadLine();
            Console.Write("Enter the Model of the car: ");
            tradeIn.Model = Console.ReadLine();
            Console.Write("Enter the Year of the car: ");
            tradeIn.Year = Int32.Parse(Console.ReadLine());
            Console.Write("Enter the List Price of the car: ");
            tradeIn.Price = Double.Parse(Console.ReadLine());
            Console.Write("Enter the Mileage of the car: ");
            tradeIn.Mileage = Double.Parse(Console.ReadLine());
            Console.Write("Enter the ID number of the car: ");
            tradeIn.Id = Int32.Parse(Console.ReadLine());
            carinventory.Add(tradeIn);
            Console.WriteLine(tradeIn.ToString());
            Console.WriteLine();
        }