Ejemplo n.º 1
0
        internal static void Run()
        {
            var garagehandler = new GarageHandler();
            int capacity      = Util.AskForInt("Please Enter Capacity of Garage to be created: ");

            garagehandler.CreateGarage(capacity);

            bool ExitProgram = false;

            while (!ExitProgram)
            {
                Console.WriteLine("Please Insert through the menu by inputting the number \n(1, 2, 3 ,4,5, 0) of your choice"
                                  + "\n1. park the Vehicles"
                                  + "\n2. Unpark the Vehicle"
                                  + "\n3. List all vehicles parked"
                                  + "\n4. Find Vehicles based on Properties "
                                  + "\n5. Search based on regno"
                                  + "\n0. Exit the application");

                char input = ' ';
                try
                {
                    input = Console.ReadLine()[0];
                }
                catch (Exception)
                {
                    Console.WriteLine("Enter valid value beteen 0 to 5");
                }

                switch (input)
                {
                case '1':
                    ParkVehicleToGarage(garagehandler);
                    break;

                case '2':
                    UnParkVehicleToGarage(garagehandler);
                    break;

                case '3':
                    ListAllVehiclesParked(garagehandler);
                    break;

                case '4':
                    FindVehiclesbasedonProperties(garagehandler);
                    break;

                case '5':
                    FindVehiclebasedonregno(garagehandler);

                    break;

                case '0':
                    ExitProgram = true;
                    break;

                default:
                    Console.WriteLine($"An unexpected input menu ({input})" +
                                      $"Enter valid value between 0 to 5 ");
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        internal static void Run()
        {
            Console.WriteLine("Please Enter Capacity of Garage to be created");
            int capacity = int.Parse(Console.ReadLine());

            var garagehandler = new GarageHandler();

            garagehandler.CreateGarage(capacity);



            bool ExitProgram = false;

            while (!ExitProgram)
            {
                Console.WriteLine("Please Insert through the menu by inputting the number \n(1, 2, 3 ,4,5,6,7, 0) of your choice"
                                  + "\n1. park the Vehicles"
                                  + "\n2. Unpark the Vehicle"
                                  + "\n3. List all vehicles parked"
                                  + "\n4. Setting maximum capacity of garage"
                                  + "\n5. Find Vehicles based on Properties "
                                  + "\n6. Search based on regno"
                                  + "\n0. Exit the application");

                char input = ' '; //Creates the character input to be used with the switch-case below.
                try
                {
                    input = Console.ReadLine()[0]; //Tries to set input to the first char in an input line
                }
                catch (IndexOutOfRangeException)   //If the input line is empty, we ask the users for some input.
                {
                    Console.Clear();
                    Console.WriteLine("Please enter some input!");
                }

                switch (input)
                {
                case '1':
                    ParkVehicleToGarage(garagehandler);
                    break;

                case '2':
                    UnParkVehicleToGarage(garagehandler);
                    break;

                //    case '3':
                //        ListAllVehiclesParked();
                //        break;

                //    case '4':
                //        SettingGarageMaxCapacity();
                //        break;

                //    case '5':
                //        FindVehiclesbasedonProperties();
                //        break;

                //    case '6':
                //        FindVehiclebasedonregno();

                //        break;
                case '0':
                    ExitProgram = true;
                    break;

                default:
                    break;
                }
            }
        }