예제 #1
0
        private void AddCarToList()
        {
            GreenPlan newCar = new GreenPlan();

            Console.WriteLine("What kind of car are you wanting to add: \n" +
                              "1. Gas\n" +
                              "2. Hybrid\n" +
                              "3. Electric\n" +
                              "(Pick corresponding number)");
            var carInput = int.Parse(Console.ReadLine());

            switch (carInput)
            {
            case 1:
                newCar.TypeOfCar = CarType.Gas;
                break;

            case 2:
                newCar.TypeOfCar = CarType.Hybrid;
                break;

            case 3:
                newCar.TypeOfCar = CarType.Electric;
                break;

            default:
                break;
            }
            Console.WriteLine("What brand is the car?");
            newCar.CarBrand = Console.ReadLine();
            Console.WriteLine("What is the car model/style?");
            newCar.CarModel = Console.ReadLine();
            Console.WriteLine("What is the average mileage for the car?(Please use numbers)");
            newCar.AverageMileage = int.Parse(Console.ReadLine());

            if (newCar.TypeOfCar == CarType.Gas)
            {
                _greenPlanRepo.AddCarToGasList(newCar);
            }

            else if (newCar.TypeOfCar == CarType.Hybrid)
            {
                _greenPlanRepo.AddCarToHybridList(newCar);
            }

            else
            {
                _greenPlanRepo.AddCarToElectricList(newCar);
            }
        }
 //Electric List
 public void AddCarToElectricList(GreenPlan electric)
 {
     _listOfElectricCars.Add(electric);
 }
 //Hybrid List
 public void AddCarToHybridList(GreenPlan hybrid)
 {
     _listOfHybridCars.Add(hybrid);
 }
 //Gas List
 public void AddCarToGasList(GreenPlan gas)
 {
     _listOfGasCars.Add(gas);
 }