private void AddCar() { int listCountCheck = carRepo.GetAllCars().Count; Console.WriteLine("Enter the new car name:"); string name = Console.ReadLine(); int numDoors = InputIntHelper("\nEnter the number of doors on this car:", "\nEnter the number of doors as a whole number"); double price = InputDoubleHelper("\nEnter the vehicle price(#####.##)", "\nEnter the vehicle price(#####.##) without $"); Console.WriteLine("\nEnter the new car type (1. Gas, 2. Hybred, 3. Electric)"); string type = Console.ReadLine(); switch (type.ToLower()) { case "1": { double MPG = InputDoubleHelper("\nEnter the Miles Per Gallon (MPG) for car:", "\nEnter the Miles Per Gallon (MPG) as a whole number"); int fuelTankSize = InputIntHelper("\nEnter the fuel capacity for car in gallons:", "\nEnter the fuel capacity as a whole number"); carRepo.AddCar(new Gas(name, numDoors, price, MPG, fuelTankSize)); break; } case "2": { double MPG = InputDoubleHelper("\nEnter the Miles Per Gallon (MPG) for car:", "\nEnter the Miles Per Gallon (MPG) as a whole number"); int power = InputIntHelper("\nEnter the horsepower for car:", "\nEnter the horsepower as a whole number"); carRepo.AddCar(new Hybred(name, numDoors, price, MPG, power)); break; } case "3": { int range = InputIntHelper("\nEnter the range for car:", "\nEnter the range as a whole number"); carRepo.AddCar(new Electric(name, numDoors, price, range)); break; } default: { Console.WriteLine("\nVehicles are limited to these three types only"); break; } } // check to see if teh list if larger (add successful) if (listCountCheck < carRepo.GetAllCars().Count) { Console.WriteLine("\nCar added to the list"); } else { Console.WriteLine("\nCar not added to the list"); } }
public void TestAdd() { bool result; result = testCarRepo.AddCar(new Hybred("Prius", 3, 35900.00, 45, 120)); result = result && testCarRepo.AddCar(new Electric("Volt", 5, 45500.00, 400)); result = result && testCarRepo.AddCar(new Gas("Charger", 4, 32500.00, 25.8, 20)); Assert.IsTrue(result); }