Beispiel #1
0
        public static void CreateGarageAndVehicles()
        {
            int numberOfParkingSpaces = 25;

            garageHandler.CreateGarage(numberOfParkingSpaces);

            if (garageHandler.SeedParkVehicles() == true)
            {
                ui.Print($"\nGarage with {numberOfParkingSpaces} parking spaces created.\n{garageHandler.VehiclesSeeded} vehicles have been parked in the garage\nPress enter to continue");
                ui.GetInput();
            }
        }
Beispiel #2
0
        private static void CreateGarage(GarageHandler handler)
        {
            Console.WriteLine("Please enter a name for the garage: (enter nothing to cancel)");
            string name = Prompt();

            if (string.IsNullOrWhiteSpace(name))
            {
                return;
            }
            if (handler.Garages.Any(x => x == name))
            {
                Console.WriteLine($"A Garage with the name '{name}' already exists");
                return;
            }

            string capacityInput;
            int    capacity;

            do
            {
                Console.WriteLine("Please enter the capacity of the garage: (enter '-1' to cancel)");
                capacityInput = Prompt();
            } while (!Int32.TryParse(capacityInput, out capacity));
            if (capacity >= 0)
            {
                handler.CreateGarage(name, capacity);
                handler.SelectGarage(name);
            }
            return;
        }
Beispiel #3
0
        //if case:1 //buildgarage() builds garage withín the given limit of 1-100,if capacity entered is  greater than 100 or less than 1,
        //diaplys an error message ,else creates a parking space within the user inputed number..
        private void BuildGarage()
        {
            Console.Clear();
            Console.WriteLine("INFORMATION:THE GARAGE HAS A LIMIT OF (1-100)");
            var count = Console.ReadLine();

            if (int.TryParse(count, out capacity))
            {
                if (capacity > 100)
                {
                    Console.WriteLine("PLEASE ENTER ANYTHING BETWEEN 1 TO 100\n");
                }
                else if (capacity < 1)
                {
                    Console.WriteLine("ENTER ATLEAST 1 NUMBER TO CAPACITY LIMIT\n");
                }
                else
                {
                    theHandler.CreateGarage(capacity);
                    Console.WriteLine($"THE GARAGE IS AVAILABLE WITH {capacity} SLOTS.\n");
                }
            }
            else
            {
                Console.WriteLine("INVALID ENTRY!!\n");
            }
        }
Beispiel #4
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;
                }
            }
        }