public bool isCarRegistered(string numberPlate) { Car tempCar = RegisteredCar.Find(rcar => rcar.NumberPlate.ToLower() == numberPlate.ToLower()); return(tempCar != null); }
public void CheckCarIn(string numberPlate) { if (!isCarRegistered(numberPlate)) { Console.WriteLine("The car is not registered yet. You cannot check unregistered car!!"); return; } Car foundCar = RegisteredCar.Find(car => car.NumberPlate.ToLower() == numberPlate.ToLower()); if (isCarCheckedIn(foundCar.ID)) { Console.WriteLine("The car is already checked in!!"); return; } CheckedInCar.Add(foundCar.ID); Console.WriteLine("The car of number plate {0} has been registered.", numberPlate); }
public void checkOutCar(string numberPlate) { if (!isCarRegistered(numberPlate)) { Console.WriteLine("The car is not registered yet. You cannot check out unregistered car!!"); return; } Car foundCar = RegisteredCar.Find(car => car.NumberPlate.ToLower() == numberPlate.ToLower()); if (!isCarCheckedIn(foundCar.ID)) { Console.WriteLine("The car is not checked in!!"); return; } CheckedInCar.Remove(foundCar.ID); Console.WriteLine("The car of number plate {0} has checked out!!", numberPlate); }