예제 #1
0
 public void RemoveSetOfRegistrationNumber(List <string> registrationNumbers)
 {
     foreach (var regPlate in registrationNumbers)
     {
         if (ListOfCars.Any(x => x.RegistrationNumber == regPlate))
         {
             Car car = ListOfCars.Find(x => x.RegistrationNumber == regPlate);
             ListOfCars.Remove(car);
         }
     }
     Count = ListOfCars.Count;
 }
예제 #2
0
 public string RemoveCar(string registrationNumber)
 {
     if (!ListOfCars.Any(x => x.RegistrationNumber == registrationNumber))
     {
         return("Car with that registration number, doesn't exist!");
     }
     else
     {
         Car carForRemove = ListOfCars.Find(x => x.RegistrationNumber == registrationNumber);
         ListOfCars.Remove(carForRemove);
         Count = ListOfCars.Count;
         return($"Successfully removed {registrationNumber}");
     }
 }
예제 #3
0
        public string AddCar(Car car)
        {
            if (ListOfCars.Any(x => x.RegistrationNumber == car.RegistrationNumber))
            {
                return("Car with that registration number, already exists!");
            }
            else if (ListOfCars.Count >= this.capacity)
            {
                return("Parking is full!");
            }

            ListOfCars.Add(car);
            Count = ListOfCars.Count;
            return($"Successfully added new car {car.Make} {car.RegistrationNumber}");
        }