Esempio n. 1
0
 public void ExitApplication()
 {
     if (GUI_IO.YesNoPrompt("Do you want to quit the application?", "Application will not quit."))
     {
         Console.WriteLine("Parking lot application is now closed.");
         Environment.Exit(0);
     }
 }
Esempio n. 2
0
        public void ShowParkLotStatusCommands(int command)
        {
            int      parkSpotIx;
            ParkSpot parkSpot;
            string   parkSpotInfo = "";

            switch (command)
            {
            case -1:

                break;

            case 0:
                parkSpotIx = GUI_IO.NumPrompt("Enter parking slot number");
                if (parkSpotIx < 0)
                {
                    return;
                }
                if (parkSpotIx >= parkLot.ParkSpots.Length)
                {
                    Console.WriteLine("The parking spot {0} doesn't exist.", parkSpotIx + 1);
                    return;
                }
                parkSpot = parkLot.ParkSpots[parkSpotIx];
                if (0 == parkSpot.Vehicles.Count)
                {
                    Console.WriteLine("The parking spot is empty.");
                    return;
                }
                for (int i = 0; i < parkSpot.Vehicles.Count; ++i)
                {
                    parkSpotInfo += parkSpot.Vehicles[i].VehicleType + " " + parkSpot.Vehicles[i].RegNum + ", ";
                }
                Console.WriteLine(parkSpotInfo.Substring(0, parkSpotInfo.Length - 2));
                break;

            case 1:
                for (int i = 0; i < parkLot.ParkSpots.Length; ++i)
                {
                    parkSpot = parkLot.ParkSpots[i];
                    if (0 < parkSpot.Vehicles.Count)
                    {
                        parkSpotInfo = (i + 1) + ": ";
                        for (int j = 0; j < parkSpot.Vehicles.Count; ++j)
                        {
                            parkSpotInfo += parkSpot.Vehicles[j].VehicleType + " " + parkSpot.Vehicles[j].RegNum + ", ";
                        }
                        Console.WriteLine(parkSpotInfo.Substring(0, parkSpotInfo.Length - 2));
                    }
                }
                break;

            default:
                break;
            }
        }
Esempio n. 3
0
        public int MainMenu()
        {
            int command;

            while (true)
            {
                command = GUI_IO.CommandMenu("Main menu", commands, "to quit the application") - 1;
                return(command);
            }
        }
Esempio n. 4
0
        public int AddMenu()
        {
            int command;

            command = GUI_IO.CommandMenu("Add a vehicle menu", commandsAdd, "to cancel") - 1;
            if (command == -1)
            {
                return(-1);
            }
            menuCommands.AddMenuCommands(command);
            return(command);
        }
Esempio n. 5
0
        public void MoveMenuCommands(int command)
        {
            string  regNum;
            int     toParkSpotIx;
            Vehicle vehicle;

            switch (command)
            {
            case -1:
                break;

            case 1:
                if (RegNumPrompt(out regNum))
                {
                    if (!parkLot.GetVehicle(regNum, out vehicle))
                    {
                        Console.Write("The vehicle doesn't exists in the parking lot.\n");
                        return;
                    }
                    parkLot.GetVehicle(regNum, out vehicle);

                    toParkSpotIx = GUI_IO.NumPrompt("To which parking spot do you want to move the " + vehicle.VehicleType.ToLower() + " " + vehicle.RegNum);
                    if (-1 == toParkSpotIx)
                    {
                        return;
                    }
                    // TODO: check park spot exists
                    //                        Console.Write("To which parking lot do you want to move the {0} {1}: ", vehicle.VehicleType.ToLower(), vehicle.RegNum);
//                        toParkSpotIx = Convert.ToInt32(Console.ReadLine());


                    if (parkLot.Move(vehicle, toParkSpotIx))
                    {
                        Console.WriteLine("Move {0} {1} parked at {2} to parking lot {3}.", vehicle.VehicleType.ToLower(), vehicle.RegNum, vehicle.ParkingSpot + 1, toParkSpotIx + 1);
                    }
                    else
                    {
                        Console.WriteLine("The {0} {1} cannot fit on parking spot: {2}", vehicle.VehicleType.ToLower(), vehicle.RegNum, toParkSpotIx + 1);
                    }
                }
                else
                {
                    Console.WriteLine("There is no vehicle in the parking lot with that registration number!");
                }
                break;

            default:
                break;
            }
        }
Esempio n. 6
0
        public void StartAppp()
        {
            menu         = new Menu();
            menuCommands = new MenuCommands(menu);
            int command;

            GUI_IO.WriteHeadLine("Parking lot application");
            Console.WriteLine("");
            while (true)
            {
                command = menu.MainMenu();
                menuCommands.MainMenuCommands(command);
            }
        }
Esempio n. 7
0
        public int ShowParkLotStatus()
        {
            int command;

            while (true)
            {
                command = GUI_IO.CommandMenu("Show parking lot status menu", commandsShowParkLotStatus, "to go back") - 1;
                if (command != -1)
                {
                    GUI_IO.WriteHeadLine(commandsShowParkLotStatus[command]);
                }
                else
                {
                    GUI_IO.WriteHeadLine("");
                }
                menuCommands.ShowParkLotStatusCommands(command);
                return(command);
            }
        }