Exemple #1
0
        public void AddCarToListTest()
        {
            GasCar carTwo = new GasCar("Nissan", "Versa", 32.5d, 140000.00m, 14);

            _carsList.AddCarToList(carTwo);

            int expected = 2;
            int actual   = _carsList.GetCarsList().Count;

            Assert.AreEqual(expected, actual);
        }
        private void AddCar()
        {
            Console.Write("Please enter the make of the car you'd like to add: ");
            string make = Console.ReadLine();

            Console.Write("Please enter the model of the car you'd like to add: ");
            string model = Console.ReadLine();

            Console.Write("How many miles per gallon does this car get? (or electric charge equivalent): ");
            double mpg = double.Parse(Console.ReadLine());

            Console.Write("What is the price of the car?: $");
            decimal price = decimal.Parse(Console.ReadLine());

            Console.Write("How many customers drive this car?: ");
            int numberOfDrivers = int.Parse(Console.ReadLine());

            Console.Write("Is this car electric, hybrid, or gas?: ");
            string carType = Console.ReadLine();

            if (carType.ToLower() == "electric")
            {
                ElectricCar eCar = new ElectricCar(make, model, mpg, price, numberOfDrivers);
                _carsList.AddCarToList(eCar);
            }
            else if (carType.ToLower() == "hybrid")
            {
                HybridCar hCar = new HybridCar(make, model, mpg, price, numberOfDrivers);
                _carsList.AddCarToList(hCar);
            }
            else if (carType.ToLower() == "gas")
            {
                GasCar gCar = new GasCar(make, model, mpg, price, numberOfDrivers);
                _carsList.AddCarToList(gCar);
            }
            else
            {
                Console.WriteLine("Please enter electric, hybrid, or gas");
            }
            Console.WriteLine("Car added\n" +
                              "Press any key to continue...");
            Console.ReadKey();
        }
Exemple #3
0
 public void Arrange()
 {
     _carsList = new GreenPlanRepository();
     _car      = new HybridCar("Toyota", "Prius", 85.00d, 18000.00m, 25);
     _carsList.AddCarToList(_car);
 }