Esempio n. 1
0
        private void changeVehicleState()
        {
            int           stateChoiceInput = 0;
            bool          isInputValid     = false;
            StringBuilder vehicleIdInput   = null;

            while (!isInputValid)
            {
                try
                {
                    OutputManager.ShowMessage("Please enter desired vehicle's id, enter Q to go back.");
                    vehicleIdInput = InputManager.GetUserInput();
                    if (checkIfPressedQuit(vehicleIdInput))
                    {
                        break;
                    }
                    OutputManager.ShowScreen <StoredVehicle.eVehicleState>("Please enter the number of the desired vehicle's new state:");
                    stateChoiceInput = InputManager.GetInputAndConvertToInt();
                    isInRange(stateChoiceInput, 1, Enum.GetNames(typeof(StoredVehicle.eVehicleState)).Length);
                    m_CurrentGarage.ChangeVehicleState(vehicleIdInput.ToString(), (StoredVehicle.eVehicleState)stateChoiceInput);
                    OutputManager.ShowMessage("Successfuly changed the vehicle state.");
                    pressToContinue();
                    isInputValid = true;
                }
                catch (FormatException ex)
                {
                    OutputManager.ShowErrorMessage(string.Format("Invalid input. {0}", ex.Message));
                    pressToContinue();
                }
                catch (ValueOutOfRangeException ex)
                {
                    OutputManager.ShowErrorMessage(string.Format("Input out of range. {0}", ex.Message));
                    pressToContinue();
                }
                catch (ArgumentException ex)
                {
                    OutputManager.ShowErrorMessage(string.Format("{0}", ex.Message));
                    pressToContinue();
                }
            }
        }
Esempio n. 2
0
        private Vehicle createNewVehicle()
        {
            bool    isInputValid     = false;
            int     userVehicleInput = 0;
            int     userEngineInput  = 0;
            Vehicle vehicleToCreate  = null;

            while (!isInputValid)
            {
                try
                {
                    OutputManager.ShowScreen <VehicleFactory.eVehicleType>("Please enter the number of the desired vehicle:");
                    userVehicleInput = InputManager.GetInputAndConvertToInt();
                    isInRange(userVehicleInput, 1, Enum.GetValues(typeof(VehicleFactory.eVehicleType)).Length);
                    OutputManager.ShowScreen <VehicleFactory.eEngineType>("Please enter the number of the desired engine type:");
                    userEngineInput = InputManager.GetInputAndConvertToInt();
                    isInRange(userEngineInput, 1, Enum.GetValues(typeof(VehicleFactory.eEngineType)).Length);
                    vehicleToCreate = VehicleFactory.CreateVehicle((VehicleFactory.eVehicleType)userVehicleInput,
                                                                   (VehicleFactory.eEngineType)userEngineInput);
                    isInputValid = true;
                }
                catch (FormatException ex)
                {
                    OutputManager.ShowErrorMessage(string.Format("Invalid input. {0}", ex.Message));
                    pressToContinue();
                }
                catch (ValueOutOfRangeException ex)
                {
                    OutputManager.ShowErrorMessage(string.Format("Input out of range. {0}", ex.Message));
                    pressToContinue();
                }
                catch (ArgumentException ex)
                {
                    OutputManager.ShowErrorMessage(ex.Message);
                    pressToContinue();
                }
            }

            return(vehicleToCreate);
        }
Esempio n. 3
0
        private void getVehicleProperties(ref Vehicle io_NewVehicleToUpdate)
        {
            bool isInputValid = false;

            while (!isInputValid)
            {
                try
                {
                    OutputManager.ShowMessage("Please enter the vehicle license number");
                    io_NewVehicleToUpdate.ID = InputManager.GetUserInput().ToString();
                    OutputManager.ShowMessage("Please enter the vehicle model name");
                    io_NewVehicleToUpdate.ModelName = InputManager.GetUserInput().ToString();
                    OutputManager.ShowMessage("Please enter current engine energy.");
                    io_NewVehicleToUpdate.Engine.CurrentEnergy = InputManager.GetInputAndConvertToFloat();
                    io_NewVehicleToUpdate.calculateCurrentEnergyPercent();
                    OutputManager.ShowMessage("Please enter the wheels manufacturer.");
                    io_NewVehicleToUpdate.SetWheelsManufacturerName(InputManager.GetUserInput().ToString());
                    OutputManager.ShowMessage("Please enter the current wheels' air pressure.");
                    io_NewVehicleToUpdate.SetWheelsAirPressure(InputManager.GetInputAndConvertToFloat());
                    isInputValid = true;
                }
                catch (FormatException ex)
                {
                    OutputManager.ShowErrorMessage(string.Format("Invalid input. {0}", ex.Message));
                    pressToContinue();
                }
                catch (ArgumentException ex)
                {
                    OutputManager.ShowErrorMessage(string.Format("{0}", ex.Message));
                    pressToContinue();
                }
                catch (ValueOutOfRangeException ex)
                {
                    OutputManager.ShowErrorMessage(string.Format("Input out of range. {0}", ex.Message));
                    pressToContinue();
                }
            }
        }
Esempio n. 4
0
        private VehicleOwner createNewVehicleOwner()
        {
            VehicleOwner newVehicleOwner = new VehicleOwner();
            bool         isInputValid    = false;

            while (!isInputValid)
            {
                try
                {
                    OutputManager.ShowMessage("Please enter the owner name:");
                    newVehicleOwner.Name = InputManager.GetUserInput().ToString();
                    OutputManager.ShowMessage("Please enter the owners phone number:");
                    newVehicleOwner.PhoneNumber = InputManager.GetUserInput().ToString();
                    isInputValid = true;
                }
                catch (ArgumentException ex)
                {
                    OutputManager.ShowErrorMessage(string.Format("{0}", ex.Message));
                    pressToContinue();
                }
            }

            return(newVehicleOwner);
        }
Esempio n. 5
0
 public void Start()
 {
     OutputManager.ShowWelcomeMessage();
     runGarageOperation();
 }