public void ParkReturnedVehicle(Vehicle VehicleReturn) { Car newCar = new Car(); MC newMC = new MC(); Bike newBike = new Bike(); Bus newBus = new Bus(); if (VehicleReturn.Size == newCar.Size) { newCar.RegPlate = VehicleReturn.RegPlate; newCar.Size = VehicleReturn.Size; newCar.ArriveTime = VehicleReturn.ArriveTime; ParkingSpot newSpot; newSpot = FindAvailableSpot(newCar); if (newSpot != null) { newSpot.AddVehicle(newCar); WriteToFile(); Console.WriteLine("Your car is now parked."); Console.ReadKey(); } else { Console.WriteLine("No empty spots available."); } } else if (VehicleReturn.Size == newMC.Size) { newMC.RegPlate = VehicleReturn.RegPlate; newMC.Size = VehicleReturn.Size; newMC.ArriveTime = VehicleReturn.ArriveTime; ParkingSpot Spot; Spot = FindAvailableSpot(newMC); Spot.AddVehicle(newMC); WriteToFile(); Console.WriteLine("Done"); } else if (VehicleReturn.Size == newBike.Size) { newBike.RegPlate = VehicleReturn.RegPlate; newBike.Size = VehicleReturn.Size; newBike.ArriveTime = VehicleReturn.ArriveTime; ParkingSpot Spot; Spot = FindAvailableSpot(newBike); Spot.AddVehicle(newBike); WriteToFile(); Console.WriteLine("Done"); } else if (VehicleReturn.Size == newBus.Size) { newBus.RegPlate = VehicleReturn.RegPlate; newBus.Size = VehicleReturn.Size; newBus.ArriveTime = VehicleReturn.ArriveTime; ParkingSpot Spot; Spot = FindAvailableSpot(newBus); Spot.AddVehicle(newBus); WriteToFile(); Console.WriteLine("Done"); } }
// Take vehicle and return first empty / available spot public void ParkVehicle() { Console.WriteLine("Park a Car or Mc?"); string VehicleChoise = Console.ReadLine(); VehicleChoise.ToLower(); Console.WriteLine("Enter registration plate: "); string input = Console.ReadLine(); switch (VehicleChoise) { case "car": Car car = new Car(); car.RegPlate = input; car.ArriveTime = DateTime.Now; ParkingSpot spot; spot = FindAvailableSpot(car); if (spot != null) { spot.AddVehicle(car); WriteToFile(); Console.WriteLine("Your car is now parked."); Console.ReadKey(); } else { Console.WriteLine("No empty spots available."); } Console.ReadKey(); break; case "mc": MC newMC = new MC(); newMC.RegPlate = input; newMC.ArriveTime = DateTime.Now; ParkingSpot Spot; Spot = FindAvailableSpot(newMC); Spot.AddVehicle(newMC); WriteToFile(); Console.WriteLine("Done"); Console.ReadKey(); break; } }
public void ParkVehicle() { Console.WriteLine("Park a Car, MC, Bike or Bus"); string VehicleChoise = Console.ReadLine(); string lowerVehiceChoise = VehicleChoise.ToLower(); string ValidVehicleChoise = DataValidation(lowerVehiceChoise); if (ValidVehicleChoise == null) { Console.WriteLine("Invalid Option."); Console.ReadKey(); } else { Console.WriteLine("Enter registration plate: "); string input = Console.ReadLine(); input = input.ToUpper(); string ValidRegPlate = DataValidation(input); if (ValidRegPlate == null) { Console.WriteLine("Invalid Reg-Plate."); } switch (lowerVehiceChoise) { case "car": Car car = new Car(); car.RegPlate = input; car.ArriveTime = DateTime.Now; ParkingSpot spot; spot = FindAvailableSpot(car); if (spot != null) { spot.AddVehicle(car); WriteToFile(); Console.WriteLine("Your car is now parked."); } else { Console.WriteLine("No empty spots available."); } Console.ReadKey(); break; case "mc": MC newMC = new MC(); newMC.RegPlate = input; newMC.ArriveTime = DateTime.Now; ParkingSpot Spot; Spot = FindAvailableSpot(newMC); if (Spot != null) { Spot.AddVehicle(newMC); WriteToFile(); Console.WriteLine("Your Mc is now parked."); } else { Console.WriteLine("No spots available to park in, sorry."); } Console.ReadKey(); break; case "bike": Bike bike = new Bike(); bike.RegPlate = input; bike.ArriveTime = DateTime.Now; ParkingSpot spot1; spot1 = FindAvailableSpot(bike); if (spot1 != null) { spot1.AddVehicle(bike); WriteToFile(); Console.WriteLine("Your bike is now parked."); Console.ReadKey(); } else { Console.WriteLine("No empty spots available."); } Console.ReadKey(); break; case "bus": Bus bus = new Bus(); bus.RegPlate = input; bus.ArriveTime = DateTime.Now; int placeToPark; placeToPark = SpotAsInt(); if (placeToPark == 0 || placeToPark == -1) { Console.WriteLine("No empty spots available."); } else { for (int i = placeToPark; i < placeToPark + 4; i++) { parkingSpots[i].vehicles.Add(bus); parkingSpots[i].AvailableSpace = 0; } WriteToFile(); } Console.ReadKey(); break; } } }