public ElectricCars Search(string make, string model) { var electric = new ElectricCars(); try { foreach (var car in _electric) { if (car.Make == make && car.Model == model) { electric.Make = car.Make; electric.Model = car.Model; electric.Year = car.Year; electric.NumberOfCityMilesPerWeek = car.NumberOfCityMilesPerWeek; electric.NumberOfHighwayMilesPerWeek = car.NumberOfHighwayMilesPerWeek; electric.MilesPerCharge = car.MilesPerCharge; } if (_electric.Count == 0) { break; } } } catch (Exception) { throw new Exception("Could not find electric car"); } return(electric); }
public void ElectricService_ShouldCreateElectricCar_IsTypeElectric() { //Act var actual = new ElectricCars("Tesla", "Model 3", 2018, 200, 0, 200.0f); //Assert Assert.IsInstanceOfType(actual, typeof(ElectricCars)); }
private static Cars CreateVehicle(int choice, string make, string model, int year, float numberOfCityMiles, float numberOfHighwayMiles, float mpgInfo) { Cars car = new Cars(); switch (choice) { case 1: var gasCar = new GasUI(new RealConsole()); GasCars gas = gasCar.CreateGas(make, model, year, numberOfCityMiles, numberOfHighwayMiles, mpgInfo); gasCar.AddGas(gas); car = gas; break; case 2: var electricCar = new ElectricUI(new RealConsole()); ElectricCars electric = electricCar.CreateElectric(make, model, year, numberOfCityMiles, numberOfHighwayMiles, mpgInfo); electricCar.AddElectric(electric); car = electric; break; case 3: var hybridCar = new HybridUI(new RealConsole()); HybridCars hybrid = hybridCar.CreateHybrid(make, model, year, numberOfCityMiles, numberOfHighwayMiles, mpgInfo); hybridCar.AddHybrid(hybrid); car = hybrid; break; default: break; } return(car); }
public void AddElectric(ElectricCars electric) { _electric.Add(electric); }
public void AddElectric(ElectricCars electric) { _realConsole.WriteLine("Would you like to add this car to the list?"); _electricService.AddElectric(electric); }
public void Arrange() { _electricService = new ElectricService(); _electricList = new List <ElectricCars>(); _electric = new ElectricCars("Tesla", "Model 3", 2018, 200, 0, 200.0f); }