public void TestGetOneCar() { testCarRepo.AddCar(new Hybred("Prius", 3, 35900.00, 45, 120)); testCarRepo.AddCar(new Electric("Volt", 5, 45500.00, 400)); testCarRepo.AddCar(new Electric("Zinger", 5, 45500.00, 400)); testCarRepo.AddCar(new Electric("Magic", 5, 45500.00, 400)); Assert.IsNotNull(testCarRepo.GetOneCar("Magic")); }
private void UpdateCar() { int listCountCheck = carRepo.GetAllCars().Count; Console.WriteLine("\nEnter the car to update:"); string name = Console.ReadLine(); // see if the car exists if (carRepo.GetOneCar(name) != null) { Console.WriteLine("\nEnter the new car name:"); string newName = Console.ReadLine(); int numDoors = InputIntHelper("\nEnter the new number of doors on this car:", "\nEnter the number of doors as a whole number"); double price = InputDoubleHelper("\nEnter the new 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.UpdateCar(name, new Gas(newName, numDoors, price, MPG, fuelTankSize)); break; } case "2": { double MPG = InputDoubleHelper("\nEnter the new Miles Per Gallon (MPG) for car:", "\nEnter the Miles Per Gallon (MPG) as a whole number"); int power = InputIntHelper("\nEnter the new horsepower for car:", "\nEnter the horsepower as a whole number"); carRepo.UpdateCar(name, new Hybred(newName, numDoors, price, MPG, power)); break; } case "3": { int range = InputIntHelper("\nEnter the range for car:", "\nEnter the range as a whole number"); carRepo.UpdateCar(name, new Electric(name, numDoors, price, range)); break; } default: { Console.WriteLine("\nVehicles are limited to these three types only"); break; } } } else { Console.WriteLine("\nNo car with that name has been entered."); } }