/// <summary> /// This method is for parking a vehicle. /// </summary> public static void ParkVehicle(string type) { Console.Clear(); Console.WriteLine("Please enter the registration number:"); string regNr = Console.ReadLine().ToUpper(); int vehicleValue = 0; if (regNr is not "EXIT" && !regNr.Contains("|") && regNr.Length < 11 && regNr.Length > 4) { (Vehicle spotsTaken, ParkingSpot occupied) = ParkingHouse.FindVehicle(regNr); if (spotsTaken is null) { if (type == "car") { Car newCar = new(regNr); vehicleValue = newCar.value; ParkingSpot spot = ParkingHouse.SpotFinder(vehicleValue); spot.FreeSpace -= vehicleValue; newCar.timeIn = DateTime.Now; spot.Vehicles.Add(newCar); ParkingHouse.BackUp(); int slot = spot.SpotNumber; Receipt(newCar, "car", slot); } else if (type == "mc") { MC newMc = new(regNr); vehicleValue = newMc.value; ParkingSpot spot = ParkingHouse.SpotFinder(vehicleValue); spot.FreeSpace -= vehicleValue; newMc.timeIn = DateTime.Now; spot.Vehicles.Add(newMc); ParkingHouse.BackUp(); int slot = spot.SpotNumber; Receipt(newMc, "mc", slot); } } else { Console.WriteLine("There is already a vehicle with that registration number parked. Please try again"); Console.ReadKey(); Parkmenu.ParkMenu(); } }
/// <summary> /// This method is for the main menu. /// </summary> public static void MainMenu() { Console.Clear(); int fillPercent = ParkingHouse.FillDegree(); Console.WriteLine($"The current fill degree is: { fillPercent } % "); MenuPrinter(); Console.WriteLine("Welcome to Prague Parking. Please type the number of your menu choice" + "\n1. Park vehicle " + " 2. Check out vehicle" + " 3. Search for and move vehicle" + " 4. Settings and help" + " 5. Close the application" + "\n"); Console.Write("Number: "); string menuChoice = Console.ReadLine(); int.TryParse(menuChoice, out int choice); if (choice >= 1 && choice <= 5) { switch (choice) { case 1: Parkmenu.ParkMenu(); break; case 2: Checkout.CheckOut(); break; case 3: Movevehicle.MoveVehicle(); break; case 4: Settingsmenu.SettingsMenu(); break; case 5: CloseApplication(); break; default: break; } } else { Console.Clear(); Console.WriteLine("Invalid input, try again"); MainMenu(); } }