Пример #1
0
        public void MainMenu()
        {
            while (true)
            {
                Console.WriteLine("\nPlease navigate through the menu by entering either of \n(1, 2, 3 , 4, 5, 6, 7 or Q of your choice:\n"
                                  + "\n1. Create a Garage."
                                  + "\n2. Auto-Populate the Garage."
                                  + "\n3. Manually Park a Vehicle."
                                  + "\n4. Find a specific parked Vehicle by Registration No."
                                  + "\n5. Get a parked Vehicle out of the Garage."
                                  + "\n6. Search for Vehicle(s) by Properties."
                                  + "\n7. List ALL Vehicles parked in the Garage."
                                  + "\n\nQ. Exit the application\n");

                Console.Write("Input > ");

                string input = Console.ReadLine();

                char nav = ' ';

                try
                {
                    nav = input[0];
                }
                catch (IndexOutOfRangeException)
                {
                    Console.Clear();
                    Console.WriteLine("\nPlease enter some input!");
                }

                switch (nav)
                {
                case '1':
                    garageHandler.CreateGarage();
                    break;

                case '2':
                    garageHandler.GaragePopulated();
                    garageHandler.PrePopulateGarage();
                    break;

                case '3':
                    garageHandler.GaragePopulated();
                    ParkManuallyMenu();
                    break;

                case '4':
                    garageHandler.FindVehicleByRegNo();
                    break;

                case '5':
                    garageHandler.GetVehicleOut();
                    break;

                case '6':
                    SearchByPropertyMenu();
                    break;

                case '7':
                    garageHandler.ListAllParkedVehicles();
                    break;

                case 'Q':                         // Exit Menu.
                case 'q':
                    Environment.Exit(0);
                    break;

                default:
                    break;
                }
            }
        }