Ejemplo n.º 1
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);
     }
 }
Ejemplo n.º 2
0
 public void UpdateGasCar(string firstName, GasCar gCar)
 {
     foreach (ElectricCar car in _electricRepo)
     {
         if (car.FirstName == firstName)
         {
             _electricRepo.Remove(car);
             _gasRepo.Add(gCar);
         }
         else
         {
             foreach (HybridCar carTwo in _hybridRepo)
             {
                 if (carTwo.FirstName == firstName)
                 {
                     _hybridRepo.Remove(carTwo);
                     _gasRepo.Add(gCar);
                 }
                 else
                 {
                     foreach (GasCar carThree in _gasRepo)
                     {
                         if (carThree.FirstName == firstName)
                         {
                             _gasRepo.Remove(carThree);
                             _gasRepo.Add(gCar);
                         }
                     }
                 }
             }
         }
     }
 }