예제 #1
0
        private void setSpecificVehicleParameters(Vehicle i_NewVehicle)
        {
            string userInput, finalStateToPrint = "Vehicle entered the garage successfully";
            bool   isSetsucceeded = false;
            Dictionary <string, MethodInfo> specificParameters = i_NewVehicle.GetSpecificParameters();

            foreach (KeyValuePair <string, MethodInfo> specificProperty in specificParameters)
            {
                do
                {
                    try
                    {
                        UI.PrintString(specificProperty.Key);
                        userInput = UI.ReadString();
                        specificProperty.Value.Invoke(i_NewVehicle, new object[] { userInput });
                        isSetsucceeded = true;
                    }
                    catch
                    {
                        UI.PrintInvalidInputMessage();
                        isSetsucceeded = false;
                    }
                } while (!isSetsucceeded);
            }

            UI.ClearScreen();
            UI.PrintString(finalStateToPrint);
        }
예제 #2
0
        public void OpenGarage()
        {
            UI.eGarageActions action;
            bool   userWantsToQuit = false;
            string openString      = "Please choose an action:";

            do
            {
                UI.PrintString(openString);
                action = UI.GetActionFromUser();
                UI.ClearScreen();
                switch (action)
                {
                case UI.eGarageActions.InsertNewVehicle:
                    insertNewVehicleToGarage();
                    break;

                case UI.eGarageActions.DisplayAllVehiclesInGarage:
                    displayVehiclesInGarage();
                    break;

                case UI.eGarageActions.ChangeTheStatusOfCar:
                    changeTheStatusOfVehicle();
                    break;

                case UI.eGarageActions.InflateTheWheels:
                    inflateTheWheels();
                    break;

                case UI.eGarageActions.Refuel:
                    refuel();
                    break;

                case UI.eGarageActions.ChargeTheBattery:
                    chargeTheBattery();
                    break;

                case UI.eGarageActions.DisplayFullDetailsOfVehicle:
                    displayFullDetailsOfVehicle();
                    break;

                case UI.eGarageActions.Quit:
                    userWantsToQuit = true;
                    break;
                }
            }while (!userWantsToQuit);
        }