Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var parkingLot = new ParkingLot();

            int userInput = 0;

            do
            {
                userInput = DisplayMenu();

                switch (userInput)
                {
                // TODO : Use enum
                case 1:
                    var mototCycle     = new MotorCycle(ReadInput(VehicleType.Motorcycle));
                    var availableFloor = parkingLot.GetEmptyFloor(VehicleType.Motorcycle);
                    if (availableFloor != null)
                    {
                        PrintParkedVeichle(availableFloor.Park(mototCycle), VehicleType.Motorcycle);
                    }
                    else
                    {
                        Console.WriteLine("No parking floors avalable");
                    }

                    break;

                case 2:
                    var car = new Car(ReadInput(VehicleType.Car));
                    if (parkingLot.GetEmptyFloor(VehicleType.Car) != null)
                    {
                        PrintParkedVeichle(parkingLot.GetEmptyFloor(VehicleType.Car).Park(car), VehicleType.Car);
                    }
                    else
                    {
                        Console.WriteLine("No parking floors avalable");
                    }
                    break;

                case 3:
                    var bus = new Bus(ReadInput(VehicleType.Bus));
                    if (parkingLot.GetEmptyFloor(VehicleType.Bus) != null)
                    {
                        PrintParkedVeichle(parkingLot.GetEmptyFloor(VehicleType.Bus).Park(bus), VehicleType.Bus);
                    }
                    else
                    {
                        Console.WriteLine("No parking floors available");
                    }
                    break;

                case 4:
                    PrintAllParkedVeichles(parkingLot);
                    break;

                case 5:
                    var vehicle = ReadInput(VehicleType.All);
                    parkingLot.UnPark(vehicle);
                    break;

                default:
                    Console.WriteLine("Incorrect choice");
                    break;
                }
            } while (userInput != 6);
        }