Ejemplo n.º 1
0
 public void UpdateElectricCar(string firstName, ElectricCar eCar)
 {
     foreach (ElectricCar car in _electricRepo)
     {
         if (car.FirstName == firstName)
         {
             _electricRepo.Remove(car);
             _electricRepo.Add(eCar);
         }
         else
         {
             foreach (HybridCar carTwo in _hybridRepo)
             {
                 if (carTwo.FirstName == firstName)
                 {
                     _hybridRepo.Remove(carTwo);
                     _electricRepo.Add(eCar);
                 }
                 else
                 {
                     foreach (GasCar carThree in _gasRepo)
                     {
                         if (carThree.FirstName == firstName)
                         {
                             _gasRepo.Remove(carThree);
                             _electricRepo.Add(eCar);
                         }
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 public void CreateNewCar(decimal carPrice, string firstName, TypeOfCar carType)
 {
     if (carType == TypeOfCar.Electric)
     {
         ElectricCar electricCar = new ElectricCar();
         electricCar.CarPrice  = carPrice;
         electricCar.CarType   = TypeOfCar.Electric;
         electricCar.FirstName = firstName;
         _electricRepo.Add(electricCar);
     }
     else if (carType == TypeOfCar.Hybrid)
     {
         HybridCar hybridCar = new HybridCar();
         hybridCar.FirstName = firstName;
         hybridCar.CarType   = TypeOfCar.Hybrid;
         hybridCar.CarPrice  = carPrice;
         _hybridRepo.Add(hybridCar);
     }
     else if (carType == TypeOfCar.Gas)
     {
         GasCar gasCar = new GasCar();
         gasCar.CarPrice  = carPrice;
         gasCar.CarType   = TypeOfCar.Gas;
         gasCar.FirstName = firstName;
         _gasRepo.Add(gasCar);
     }
 }