예제 #1
0
        /// <summary>
        /// park a vehicle based on their vehicle type
        /// </summary>
        /// <param name="parkingLot"></param>
        private static void ParkVehicle(VehicleType vehicleType, ParkingLot parkingLot)
        {
            ParkingSlot parkingSlot = parkingLot.GetAvailableSlot(vehicleType);

            if (parkingSlot != null)
            {
                Vehicle vehicle = GetVehicle(vehicleType);
                Console.WriteLine("enter vehicle number");
                int vehicleNumber = GetUserInput();
                if (!parkingLot.IsVehicleAndTicketExist(vehicleNumber))
                {
                    vehicle.VehicleNumber = vehicleNumber;
                    parkingLot.ParkVehicle(vehicle);
                    Console.WriteLine("your parking slot has been allocated");
                }
                else
                {
                    Console.WriteLine("vehicle number already exist");
                }
            }
            else
            {
                Console.WriteLine("Sorry,there are no slots available!!");
            }
            Console.WriteLine("press any key to continue");
            Console.ReadKey();
        }
예제 #2
0
        public void ParkVehicle(Vehicle vehicle)
        {
            ParkingSlot parkingSlot = GetAvailableSlot(vehicle.Type);
            int         slotNumber  = parkingSlot.ParkAVehicle(vehicle);

            parkingSlot.ParkingTicket = IssueTicket(vehicle.VehicleNumber, vehicle.Type, slotNumber);
        }
예제 #3
0
        static void Main(string[] args)
        {
            ParkingLot parkingLot = new ParkingLot();

            Intialize(parkingLot);

            bool isExit = false;

            while (!isExit)
            {
                Console.WriteLine("1. Parking Lot Current Occupancy details");
                Console.WriteLine("2. Park a Vehicle");
                Console.WriteLine("3. UnPark a Vehicle");
                Console.WriteLine("0. Back");
                Console.WriteLine("please a select a menu option");
                int menuOption = GetUserInput();
                switch (menuOption)
                {
                case 1:
                    DisplayOccupancyDetails(parkingLot);
                    break;

                case 2:
                    DisplayParkMenu(parkingLot);
                    break;

                case 3:
                    Console.WriteLine("PLease enter Vehicle Number");
                    int vehicleNumber = GetUserInput();
                    if (parkingLot.IsVehicleNumberExist(vehicleNumber))
                    {
                        ParkingSlot parkingSlot = parkingLot.GetParkingSlotOfVehicleNumber(vehicleNumber);
                        parkingSlot.UnParkVehicle();
                        parkingLot.ChangeTicketStatus(parkingSlot.ParkingTicket);
                        Console.WriteLine("vehicle has been successfully Unparked");
                        Console.ReadKey();
                    }
                    else
                    {
                        Console.WriteLine("Vehicle number doesnt exist");
                        Console.WriteLine("press any key to continue");
                        Console.ReadKey();
                    }
                    break;

                case 0:
                    isExit = true;
                    break;

                default:
                    Console.WriteLine("option doesnt exist");
                    break;
                }
            }
        }
예제 #4
0
 public void AddParkingSlot(ParkingSlot parkingSlot)
 {
     ParkingSlots.Add(parkingSlot);
 }