static void Main(string[] args) { while (true) { Console.WriteLine(Menu); string choise = ReadInput(); if (int.TryParse(choise, out int num) && Enumerable.Range(1, 9).Contains(num)) { switch (num) { case 1: Console.WriteLine($"The balance of ParkingLot is {Parking.GetInstance().Balance}"); break; case 2: Console.WriteLine($"The amount of money earned for last minute is { TransactionsViewer.ShowLastMinuteIncome()}"); break; case 3: Console.WriteLine($"There are {Settings.capacity - Parking.GetInstance().vehicles.Count} spare places at the parking."); break; case 4: TransactionsViewer.ViewLastMinuteTransactions(); break; case 5: TransactionsLogger.ShowAllTranactions(); break; case 6: VehicleViewer.ShowParkedVehicle(); break; case 7: new VehicleCreator().AddVehicle(); TransactionsLogger.LogTransactions(); break; case 8: VehicleRemover.TakeVehicle(); break; case 9: VehicleAccount.FundAccount(VehicleViewer.FindVehicle(VehicleViewer.ReadLicenseNumber())); break; } } else { Console.WriteLine("Incorrect input. Try again!"); } } }
/// <summary> /// Check whether the vehicle is parked. /// </summary> public static void TakeVehicle() { var id = VehicleViewer.ReadLicenseNumber(); if (VehicleViewer.IsParked(id)) { var v = VehicleViewer.FindVehicle(id); check : if (v.Balance < 0) { Console.WriteLine($"You have a debt for parking in amount of {v.Balance}. Please fund your account."); VehicleAccount.FundAccount(v); goto check; } v.IsParked = false; Parking.GetInstance().vehicles.Remove(v); Console.WriteLine("Taking vehicle is successful."); } else { Console.WriteLine($"There is no vehicle with license number {id}"); } }