Ejemplo n.º 1
0
        private void getDetailsAndRefuel()
        {
            Console.WriteLine("Please enter the license number of the vehicle you would like to refuel");
            string licenseNumber = ValidateUserInput.ValidateInputInNotEmpty();

            Console.Clear();
            Console.WriteLine("Please enter the type of fuel of the vehicle you would like to refuel");
            Gas.eFuelType fuelType = (Gas.eFuelType)ValidateUserInput.InputIsInRangeOfEnum(typeof(Gas.eFuelType));
            Console.Clear();
            Console.WriteLine("Please enter the amount of fuel you would like to refuel");
            float amountOfFuel = ValidateUserInput.ParseInputToFloat();

            try
            {
                m_UserInterface.Garage.RefuelGasVehicle(licenseNumber, fuelType, amountOfFuel);
                Console.Clear();
                Console.WriteLine(String.Format("Vehicle with license number: {0}, was refueled with gas type: {1}, and amount: {2} successfuly!", licenseNumber, fuelType, amountOfFuel));
                Messages.PressAnyKeyToContinue();
            }
            catch (Exception exception)
            {
                Console.Clear();
                Console.WriteLine(exception.Message);

                if (exception is ValueOutOfRangeException)
                {
                    Console.WriteLine("Please try again");
                    getDetailsAndRefuel();
                }
                else
                {
                    Messages.PressAnyKeyToContinue();
                }
            }
        }
Ejemplo n.º 2
0
        private void getDetailsAndChargeVehicle()
        {
            Console.WriteLine("Please enter the license number of the vehicle you would like to recharge");
            string licenseNumber = ValidateUserInput.ValidateInputInNotEmpty();

            Console.Clear();
            Console.WriteLine("Please enter the number of minutes to charge");
            float amountOfTimeToCharge = ValidateUserInput.ParseInputToFloat();

            try
            {
                m_UserInterface.Garage.RechargeElectricVehicle(licenseNumber, amountOfTimeToCharge);
                Console.Clear();
                Console.WriteLine(String.Format("Vehicle with license number: {0}, with amount: {1} successfuly!", licenseNumber, amountOfTimeToCharge));
                Messages.PressAnyKeyToContinue();
            }

            catch (Exception exception)
            {
                Console.Clear();
                Console.WriteLine(exception.Message);

                if (exception is ValueOutOfRangeException)
                {
                    Console.WriteLine("Please try again");
                    getDetailsAndChargeVehicle();
                }
                else
                {
                    Messages.PressAnyKeyToContinue();
                }
            }
        }
Ejemplo n.º 3
0
        private string getCarModel()
        {
            m_UserDisplay.ClearAndDisplayMessage("Please enter the vehicle model name");
            string carModelName = ValidateUserInput.ValidateInputInNotEmpty();

            return(carModelName);
        }
Ejemplo n.º 4
0
        private void addWheelsManufacturer(List <Wheel> wheels)
        {
            m_UserDisplay.ClearAndDisplayMessage("Please enter Wheels Manufacturer name");
            string ManufacturerOfWheels = ValidateUserInput.ValidateInputInNotEmpty();

            foreach (Wheel wheel in wheels)
            {
                wheel.Manufacturer = ManufacturerOfWheels;
            }
        }
Ejemplo n.º 5
0
 public VehicleDetailsProvider(Garage i_Garage)
 {
     this.m_Garage = i_Garage;
     Console.Clear();
     Console.WriteLine("You have chosen to get a vehicle details");
     Console.WriteLine("Please enter the license number of the vehicle to show its details");
     this.m_LicenseNumber = ValidateUserInput.GetLicensePlateFromUser();
     Console.Clear();
     getVehicleDetails();
 }
        public void ServeUser()
        {
            int userChoise = 0;

            m_UserDisplay.DisplayMessage(Messages.k_WelcomeUserMessage);
            m_UserDisplay.ReadLine();

            while (userChoise != (int)Messages.eMainMenuOptions.Exit)
            {
                m_UserDisplay.ClearAndDisplayMessage(Messages.k_Menu);
                userChoise = ValidateUserInput.getUserChoice();
                if (userChoise == (int)Messages.eMainMenuOptions.AddNewVehicle)
                {
                    m_GarageController.AddVehicleToGarage();
                }
                else if (userChoise == (int)Messages.eMainMenuOptions.DisplayAllLicensePlates)
                {
                    m_GarageController.displayLicenseNumbersList();
                }
                else if (userChoise == (int)Messages.eMainMenuOptions.ChangeStatus)
                {
                    m_GarageController.changeCarStatus();
                }
                else if (userChoise == (int)Messages.eMainMenuOptions.RefuelFuelEngine)
                {
                    m_GarageController.refuelGasVehicle();
                }
                else if (userChoise == (int)Messages.eMainMenuOptions.RechargeElectricEngine)
                {
                    m_GarageController.chargeElectricVehicle();
                }
                else if (userChoise == (int)Messages.eMainMenuOptions.InflateWheels)
                {
                    m_GarageController.InflateTires();
                }
                else if (userChoise == (int)Messages.eMainMenuOptions.DisplayVehicleDetails)
                {
                    m_GarageController.printVehicleDetails();
                }
            }

            m_UserDisplay.GoodByePrinter();
        }
Ejemplo n.º 7
0
        private void setWheelsCurrentAirPressure(List <Wheel> wheels)
        {
            m_UserDisplay.ClearAndDisplayMessage("Please enter the current air pressure of the wheels");

            float currentAirPressure = ValidateUserInput.ParseInputToFloat();

            try
            {
                foreach (Wheel wheel in wheels)
                {
                    wheel.PumpAir(currentAirPressure);
                }
            }
            catch (Exception exception)
            {
                m_UserDisplay.displayExceptionMessage(exception);
                setWheelsCurrentAirPressure(wheels);
            }
        }
        public Vehicle.eVehicleGarageStatus GetFilter()
        {
            m_UserDisplay.ClearAndDisplayMessage("You have chosen to Display the license numbers of the vehicles whom are currently in the garage");
            m_UserDisplay.DisplayMessage("Would you like to filter according to the status of each vehicle? Press Y for 'Yes' or N For 'No'");
            bool userWantsToFilter = ValidateUserInput.validateYesOrNo();

            Vehicle.eVehicleGarageStatus vehicleStatus;

            if (userWantsToFilter)
            {
                vehicleStatus = ValidateUserInput.GetStateFromUser();
            }
            else
            {
                vehicleStatus = Vehicle.eVehicleGarageStatus.Undefined;
            }

            return(vehicleStatus);
        }
Ejemplo n.º 9
0
        public void InflateTires()
        {
            m_UserDisplay.ClearAndDisplayMessage("You have chosen to Inflate a vehicle tires to maximum");
            m_UserDisplay.DisplayMessage("Please enter the license number of the vehicle you want to inflate air to");
            string licensePlate = ValidateUserInput.GetLicensePlateFromUser();

            try
            {
                m_Garage.FillAirToMaximum(licensePlate);
                m_UserDisplay.ClearAndDisplayMessage(string.Format("{0} Wheels pumped to Maximum!", licensePlate));
            }
            catch (Exception exception)
            {
                m_UserDisplay.ClearAndDisplayMessage(exception.Message);
            }
            finally
            {
                m_UserDisplay.PressAnyKeyToContinue();
            }
        }
Ejemplo n.º 10
0
        public void printVehicleDetails()
        {
            m_UserDisplay.ClearAndDisplayMessage("You have chosen to get a vehicle details");
            m_UserDisplay.DisplayMessage("Please enter the license number of the vehicle to show its details");

            try
            {
                string licenseNumber = ValidateUserInput.GetLicensePlateFromUser();
                m_Garage.IsVehicleInGarageException(licenseNumber);
                m_UserDisplay.Clear();
                m_UserDisplay.DisplayMessage(m_Garage.GetVehicleByLicenseNumber(licenseNumber).ToString());
            }
            catch (ArgumentException exception)
            {
                m_UserDisplay.displayExceptionMessage(exception);
            }
            finally
            {
                m_UserDisplay.PressAnyKeyToContinue();
            }
        }
Ejemplo n.º 11
0
        public InflateTires(UserInterface i_UserInterface)
        {
            m_UserInterface = i_UserInterface;
            Console.Clear();
            Console.WriteLine("You have chosen to Inflate a vehicle tires to maximum");
            Console.WriteLine("Please enter the license number of the vehicle you want to inflate air to");
            string licensePlate = ValidateUserInput.GetLicensePlateFromUser();

            try
            {
                m_UserInterface.Garage.FillAirToMaximum(licensePlate);
                Console.Clear();
                Console.WriteLine(String.Format("{0} Wheels pumped to Maximum!", licensePlate));
                Messages.PressAnyKeyToContinue();
            }
            catch (Exception exepetion)
            {
                Console.Clear();
                Console.WriteLine(exepetion.Message);
                Messages.PressAnyKeyToContinue();
            }
        }
Ejemplo n.º 12
0
        private void setCurrentAmountOfEnergy(Vehicle vehicle)
        {
            if (vehicle.EnergySource is Gas)
            {
                m_UserDisplay.ClearAndDisplayMessage("Please enter current amount of fuel in liters");
            }
            else
            {
                m_UserDisplay.ClearAndDisplayMessage("Please enter remaining time of engine operation in hours");
            }

            float amountOfEnergy = ValidateUserInput.ParseInputToFloat();

            try
            {
                vehicle.EnergySource.FillEnergy(amountOfEnergy);
            }
            catch (Exception exception)
            {
                m_UserDisplay.displayExceptionMessage(exception);
                setCurrentAmountOfEnergy(vehicle);
            }
        }
Ejemplo n.º 13
0
 private Motorcycle.eLicenseType assignLicenseType()
 {
     m_UserDisplay.ClearAndDisplayMessage("Please choose  Motorcycle LicenseType: ");
     return((Motorcycle.eLicenseType)ValidateUserInput.InputIsInRangeOfEnum(typeof(Motorcycle.eLicenseType)));
 }
Ejemplo n.º 14
0
        public static string GetLicensePlateFromUser()
        {
            string licenseNumber = ValidateUserInput.ValidateInputInNotEmpty();

            return(licenseNumber);
        }
Ejemplo n.º 15
0
 private Car.eNumberOfDoors installDoors()
 {
     userDisplay.ClearAndDisplayMessage("Please choose the number of Doors: ");
     return((Car.eNumberOfDoors)ValidateUserInput.InputIsInRangeOfEnum(typeof(Car.eNumberOfDoors)));
 }
Ejemplo n.º 16
0
 private Car.eCarColor paintCar()
 {
     userDisplay.ClearAndDisplayMessage("Please choose car color: ");
     return((Car.eCarColor)ValidateUserInput.InputIsInRangeOfEnum(typeof(Car.eCarColor)));
 }
Ejemplo n.º 17
0
 public Vehicle.eVehicleGarageStatus GetGarageStatus()
 {
     return(ValidateUserInput.GetStateFromUser());
 }
Ejemplo n.º 18
0
 public string GetLicenseNumberForChangingStatus()
 {
     m_UserDisplay.DisplayMessage("Please enter the license number of the vehicle whose status you would like to change");
     return(ValidateUserInput.GetLicensePlateFromUser());
 }
 public Gas.eFuelType GetFuelTypeForRefuel()
 {
     m_UserDisplay.DisplayMessage("Please enter the type of fuel of the vehicle you would like to refuel");
     return((Gas.eFuelType)ValidateUserInput.InputIsInRangeOfEnum(typeof(Gas.eFuelType)));
 }
 public float GetAmountOfLitersToFuel()
 {
     m_UserDisplay.ClearAndDisplayMessage("Please enter the amount of fuel you would like to refuel");
     return(ValidateUserInput.ParseInputToFloat());
 }
Ejemplo n.º 21
0
 private string getUsersName()
 {
     m_UserDisplay.ClearAndDisplayMessage("Please tell us your name");
     return(ValidateUserInput.ValidateInputInNotEmpty());
 }
Ejemplo n.º 22
0
 private float setMaxCarrey()
 {
     m_UserDisplay.ClearAndDisplayMessage("Please choose the truck maximum volume of cargo");
     return(ValidateUserInput.ParseInputToFloat());
 }
 public float GetAmountOfMinutesToCharge()
 {
     m_UserDisplay.ClearAndDisplayMessage("Please enter the number of minutes to charge");
     return(ValidateUserInput.ParseInputToFloat());
 }
Ejemplo n.º 24
0
 private string getUsersPhoneNumber()
 {
     m_UserDisplay.ClearAndDisplayMessage("Please tell us your phone number");
     return(ValidateUserInput.ValidateInputInNotEmpty());
 }
Ejemplo n.º 25
0
 private string getLicensePlateNumber()
 {
     m_UserDisplay.ClearAndDisplayMessage("Please enter the license number of the vehicle you want to add");
     return(ValidateUserInput.GetLicensePlateFromUser());
 }
Ejemplo n.º 26
0
 private VehicleFactory.eVehicleTypes getVehicleType()
 {
     m_UserDisplay.DisplayMessage("Please choose one of the following vehicle types:");
     return((VehicleFactory.eVehicleTypes)ValidateUserInput.InputIsInRangeOfEnum(typeof(VehicleFactory.eVehicleTypes)));
 }
 public string GetLicenseNumberForCharging()
 {
     m_UserDisplay.DisplayMessage("Please enter the license number of the vehicle you would like to recharge");
     return(ValidateUserInput.ValidateInputInNotEmpty());
 }
Ejemplo n.º 28
0
 public string GetLicenseNumberForRefuel()
 {
     m_UserDisplay.ClearAndDisplayMessage("Please enter the license number of the vehicle you would like to refuel");
     return(ValidateUserInput.ValidateInputInNotEmpty());
 }
Ejemplo n.º 29
0
 private int setEngineVolume()
 {
     m_UserDisplay.ClearAndDisplayMessage("Please choose the engine volume: ");
     return(ValidateUserInput.ParseInputToInt());
 }
Ejemplo n.º 30
0
 private bool setIfCarryingDangerousMaterials()
 {
     m_UserDisplay.ClearAndDisplayMessage("Please choose whether the truck will carry dangerous materials chose Y to 'Yes' and N to 'No'");
     return(ValidateUserInput.validateYesOrNo());
 }