public void CreateCar()
        {
            Console.Clear();
            Console.WriteLine("What type of car is this?\n" +
                              "1. Electric\n" +
                              "2. Hybrid\n" +
                              "3. Gas\n" +
                              "4. Cancel\n");
            string input     = Console.ReadLine();
            int    createInt = int.Parse(input);

            if (createInt == 1 || createInt == 2 || createInt == 3)
            {
                Console.WriteLine("\nEnter the make:");
                string make = Console.ReadLine();
                Console.WriteLine("\nEnter the model:");
                string model = Console.ReadLine();
                Console.WriteLine("\nEnter the year:");
                int year = int.Parse(Console.ReadLine());
                Console.WriteLine("\nEnter the MPG / MPGe:");
                decimal mpg    = decimal.Parse(Console.ReadLine());
                Car     newCar = new Car(make, model, year, mpg, (CarTypes)createInt - 1);
                carRepo.AddCar(newCar);
            }
            Console.Clear();
        }
예제 #2
0
        private void InitCars()
        {
            Car[] car = new Car[9];
            car[0] = new Car("Tesla", "Model S", 2017, 125.00m, CarTypes.Electric);
            car[1] = new Car("Nissan", "Leaf", 2018, 125.00m, CarTypes.Electric);
            car[2] = new Car("Volkswagon", "e-Golf", 2017, 126.00m, CarTypes.Electric);
            car[3] = new Car("Toyota", "Prius", 2017, 43.00m, CarTypes.Hybrid);
            car[4] = new Car("Ford", "Fusion", 2018, 34.00m, CarTypes.Hybrid);
            car[5] = new Car("Honda", "Accord", 2018, 38.00m, CarTypes.Hybrid);
            car[6] = new Car("Honda", "Civic", 2018, 32.00m, CarTypes.Gas);
            car[7] = new Car("Ford", "Mustang", 2019, 21.00m, CarTypes.Gas);
            car[8] = new Car("Chrysler", "Pacifica", 2019, 19.00m, CarTypes.Gas);

            for (int i = 0; i < car.Length; i++)
            {
                _carRepo.AddCar(car[i]);
            }
        }