///////////////// PARK VEHICLES ///////////////// //////////////// MC //////////////// public static void ParkMC() { if (ParkingSpaces.parkingSpots.Count == 0) { ParkingSpaces.parkingSpots = Car.CreateSpaces(); } foreach (ParkingList extraMc in ParkingSpaces.parkingSpots) { if (extraMc.availableSpace == 4) { AnsiConsole.Render( new Panel(new Text($"\nPlease enter license number: \n").Centered()) .Expand() .SquareBorder() .Header("[red]Park An MC[/]") .HeaderAlignment(Justify.Center)); string userInput = Console.ReadLine().ToUpper(); Mc mc = new Mc(userInput, TimeCheckin()); extraMc.parkingList.Add(mc); AnsiConsole.Render( new Panel(new Text($"{mc.VehicleType} with license plate {userInput}\nParked at time: {mc.TimeStamp}\nSpace left: Room for 1 more Mc.").Centered()) .Expand() .SquareBorder() .Header("[green]Park An Mc[/]") .HeaderAlignment(Justify.Center)); extraMc.availableSpace = extraMc.availableSpace -= 2; ReadData.SerializeObject(); Console.ReadKey(); break; } if (extraMc.availableSpace == 2) { AnsiConsole.Render( new Panel(new Text($"\nPlease enter license number: \n").Centered()) .Expand() .SquareBorder() .Header("[red]Park An MC[/]") .HeaderAlignment(Justify.Center)); string userInput = Console.ReadLine().ToUpper(); Mc mc = new Mc(userInput, Vehicle.TimeCheckin()); extraMc.parkingList.Add(mc); AnsiConsole.Render( new Panel(new Text($"{mc.VehicleType} with license plate {userInput}\nParked at time: {mc.TimeStamp}\nSpace left: Parking space is now full.").Centered()) .Expand() .SquareBorder() .Header("[green]Park An MC[/]") .HeaderAlignment(Justify.Center)); extraMc.availableSpace = extraMc.availableSpace -= 2; ReadData.SerializeObject(); Console.ReadKey(); break; } } }
////////////// CHECK OUT VEHICLES /////////////// public static void RemoveVehicle() { AnsiConsole.Render( new Panel(new Text($"\nTo check out vehicle please enter License number: \n").Centered()) .Expand() .SquareBorder() .Header("[red]Check Out Menu[/]") .HeaderAlignment(Justify.Center)); TimeStampOut = TimeCheckin(); LicenseChoice = Console.ReadLine().ToUpper(); List <ParkingList> spaces = ParkingSpaces.parkingSpots; foreach (ParkingList parkingSpot in spaces) { foreach (Vehicle vehicle in parkingSpot.parkingList) { if (LicenseChoice.Equals(vehicle.LicensePlate) && vehicle.CarSize == 4) { i = ParkingSpaces.parkingSpots.IndexOf(parkingSpot); TimeStampOut = Vehicle.TimeCheckin(); AnsiConsole.Render( new Panel(new Text($"Car was found at spot: {i + 1}\nCheck in time:{vehicle.TimeStamp}\nCheck out time: {TimeStampOut}").Centered()) .Expand() .SquareBorder() .Header("[green]Check Out Menu[/]") .HeaderAlignment(Justify.Center)); Console.ReadKey(); parkingSpot.parkingList.RemoveAt(0); parkingSpot.availableSpace = 4; ReadData.SerializeObject(); break; } if (LicenseChoice.Equals(vehicle.LicensePlate) && vehicle.CarSize == 2) { i = ParkingSpaces.parkingSpots.IndexOf(parkingSpot); TimeStampOut = Vehicle.TimeCheckin(); AnsiConsole.Render( new Panel(new Text($"Mc was found at spot: {i + 1}\nCheck in time:{vehicle.TimeStamp}\nCheck out time: {TimeStampOut}").Centered()) .Expand() .SquareBorder() .Header("[green]Check Out Menu[/]") .HeaderAlignment(Justify.Center)); Console.ReadKey(); parkingSpot.parkingList.RemoveAt(0); parkingSpot.availableSpace += 2; ReadData.SerializeObject(); break; } } } }
/////////////// MOVE VEHICLES /////////////// public static void MoveVehicle() { i = 0; j = 0; AnsiConsole.Render( new Panel(new Text($"\nTo move a vehicle please enter license number: \n").Centered()) .Expand() .SquareBorder() .Header("[red]Move A Vehicle[/]") .HeaderAlignment(Justify.Center)); LicenseChoice = Console.ReadLine().ToUpper(); List <ParkingList> spaces = ParkingSpaces.parkingSpots; foreach (ParkingList parkingSpot in spaces) { foreach (Vehicle vehicle in parkingSpot.parkingList) { if (LicenseChoice.Equals(vehicle.LicensePlate) && vehicle.CarSize == 4) { i = ParkingSpaces.parkingSpots.IndexOf(parkingSpot); AnsiConsole.Render( new Panel(new Text($"{vehicle.VehicleType} with license number: {LicenseChoice} \nParked at spot: {i}\nProceed to next step to choose a new spot").Centered()) .Expand() .SquareBorder() .Header("[green]Move A Vehicle[/]") .HeaderAlignment(Justify.Center)); Console.ReadLine(); parkingSpot.parkingList.RemoveAt(0); AnsiConsole.Render( new Panel(new Text($"\nPlease choose a new parking spot: \n").Centered()) .Expand() .SquareBorder() .Header("[red]Move A Vehicle[/]") .HeaderAlignment(Justify.Center)); SpaceChoice = Int32.Parse(Console.ReadLine()); parkingSpot.parkingList.Insert(SpaceChoice, vehicle); parkingSpot.availableSpace = 4; ReadData.SerializeObject(); break; } if (LicenseChoice.Equals(vehicle.LicensePlate) && vehicle.CarSize == 2) { i = ParkingSpaces.parkingSpots.IndexOf(parkingSpot); AnsiConsole.Render( new Panel(new Text($"{vehicle.VehicleType} with license number: {LicenseChoice} \nParked at spot: {i}\nProceed to next step to choose a new spot").Centered()) .Expand() .SquareBorder() .Header("[green]Move A Vehicle[/]") .HeaderAlignment(Justify.Center)); Console.ReadLine(); parkingSpot.parkingList.RemoveAt(0); AnsiConsole.Render( new Panel(new Text($"\nPlease choose a new parking spot: \n").Centered()) .Expand() .SquareBorder() .Header("[red]Move A Vehicle[/]") .HeaderAlignment(Justify.Center)); SpaceChoice = Int32.Parse(Console.ReadLine()); parkingSpot.parkingList.Insert(SpaceChoice, vehicle); parkingSpot.availableSpace += 2; ReadData.SerializeObject(); break; } } } }