internal void ShowVehiclesWithFilter()
        {
            VehicleGarageInfo.eVehicleCondition vehicleCondition;

            while (true)
            {
                try
                {
                    vehicleCondition = (VehicleGarageInfo.eVehicleCondition)InputValidation.EnumChoiseToInt(typeof(VehicleGarageInfo.eVehicleCondition), UserConsole.ChooseString("vehicle condition"));
                    UserConsole.Print(string.Format("All vehicles in the garage that are {0}:", vehicleCondition.ToString()));
                    UserConsole.Print(r_Garage.VehicleInGarageToString(vehicleCondition));
                    break;
                }
                catch (Exception ex)
                {
                    UserConsole.ExceptionOutput(ex);
                }
                finally
                {
                    UserConsole.PrintAndRead("Press any key to go back to vehicle menu");
                    endAction();
                }
            }

            endAction();
        }
        internal void AddVehicleToGarage()
        {
            Vehicle vehicle;

            VehicleCreater.eVehicleTypes vehicleType;
            while (true)
            {
                try
                {
                    vehicleType = (VehicleCreater.eVehicleTypes)InputValidation.EnumChoiseToInt(typeof(VehicleCreater.eVehicleTypes),
                                                                                                UserConsole.ChooseString("vehicle type"));
                    vehicle = VehicleCreater.InitVehicle(vehicleType);
                    vehicle.LicenseNumber = InputValidation.GetString("\nEnter License number: ");
                    vehicle.ModelName     = InputValidation.GetString("\nEnter model Name: ");
                    r_Garage.AddVehicleToGarage(vehicle);
                    break;
                }
                catch (Exception ex)
                {
                    UserConsole.ExceptionOutput(ex);
                }
            }

            vehicle.VehicleInfo = setVehicleInfo();
            setEnergy(vehicle);
            UserConsole.SleepAndClear();
            setWheelInfo(vehicle);
            UserConsole.Print("\n");
            setExtraDeatails(vehicle);
            UserConsole.Print("\nVehicle was added successfully!");
            endAction();
        }
        private void setWheelInfo(Vehicle i_Vehicle)
        {
            float  airInput;
            string wheelManufacture;

            while (true)
            {
                try
                {
                    wheelManufacture = InputValidation.GetString("\nEnter wheel manufacture: ");
                    airInput         = InputValidation.GetFloat("\nEnter how much air you want to add to the wheels: ");
                    foreach (Wheel wheel in i_Vehicle.Wheels)
                    {
                        wheel.InflateWheel(airInput);
                        wheel.ManufacturerName = wheelManufacture;
                    }

                    break;
                }
                catch (Exception ex)
                {
                    UserConsole.ExceptionOutput(ex);
                }
            }
        }
 private void setTruckInfo(Truck i_Truck)
 {
     while (true)
     {
         try
         {
             i_Truck.ContainsDangerousMaterials = InputValidation.GetBool("\nDoes truck contains dangerous materials? ");
             i_Truck.MaxCarryWeight             = InputValidation.GetFloat("\nEnter max carry weight: ");
             break;
         }
         catch (Exception ex)
         {
             UserConsole.ExceptionOutput(ex);
         }
     }
 }
 private void setMotorcycleInfo(Motorcycle i_Motorcycle)
 {
     while (true)
     {
         try
         {
             i_Motorcycle.LicenseType  = (Motorcycle.eLicenseType)InputValidation.EnumChoiseToInt(typeof(Motorcycle.eLicenseType), UserConsole.ChooseString("license type"));
             i_Motorcycle.EngineVolume = InputValidation.GetPositiveInt("\nEnter Engine volume: ");
             break;
         }
         catch (Exception ex)
         {
             UserConsole.ExceptionOutput(ex);
         }
     }
 }
 private void setCarInfo(Car i_Car)
 {
     while (true)
     {
         try
         {
             i_Car.Color         = (Car.eColor)InputValidation.EnumChoiseToInt(typeof(Car.eColor), UserConsole.ChooseString("car color"));
             i_Car.NumberOfDoors = (Car.eNumberOfDoors)InputValidation.EnumChoiseToInt(typeof(Car.eNumberOfDoors), UserConsole.ChooseString("number of doors for car"));
             break;
         }
         catch (Exception ex)
         {
             UserConsole.ExceptionOutput(ex);
         }
     }
 }
 internal void ShowAllVehicles()
 {
     try
     {
         UserConsole.Print("All vehicals in the garage: \n");
         UserConsole.Print(r_Garage.VehicleInGarageToString());
     }
     catch (Exception ex)
     {
         UserConsole.ExceptionOutput(ex);
     }
     finally
     {
         UserConsole.PrintAndRead("Press any key to go back to vehicle menu");
         endAction();
     }
 }
Exemplo n.º 8
0
        internal void FillAirWheels()
        {
            while (true)
            {
                try
                {
                    r_Garage.FillAirToMax(r_Vehicle.LicenseNumber);
                    break;
                }
                catch (Exception ex)
                {
                    UserConsole.ExceptionOutput(ex);
                }
            }

            UserConsole.Print("Filling air finished!");
            endAction();
        }
Exemplo n.º 9
0
        internal void ChangeVehicleStatus()
        {
            while (true)
            {
                try
                {
                    VehicleGarageInfo.eVehicleCondition vehicleStatus = (VehicleGarageInfo.eVehicleCondition)InputValidation.EnumChoiseToInt(typeof(VehicleGarageInfo.eVehicleCondition), UserConsole.ChooseString("vehicle condition"));
                    r_Garage.ChangeVehicleCondition(r_Vehicle.LicenseNumber, vehicleStatus);
                    break;
                }
                catch (Exception ex)
                {
                    UserConsole.ExceptionOutput(ex);
                }
            }

            endAction();
        }
        private VehicleGarageInfo setVehicleInfo()
        {
            VehicleGarageInfo vehicleGarageInfo;

            while (true)
            {
                try
                {
                    string ownerName   = InputValidation.GetString("\nEnter owner Name: ");
                    string ownerNumber = InputValidation.GetStringNumber("\nEnter owner phone number: ");
                    vehicleGarageInfo = new VehicleGarageInfo(ownerName, ownerNumber);
                    break;
                }
                catch (Exception ex)
                {
                    UserConsole.ExceptionOutput(ex);
                }
            }

            return(vehicleGarageInfo);
        }
        private float setElectric(Vehicle i_Vehicle)
        {
            float energyAmount = 0;

            while (true)
            {
                try
                {
                    ElectricEngine ElectricEngine = i_Vehicle.Engine as ElectricEngine;
                    UserConsole.SleepAndClear();
                    energyAmount = InputValidation.GetFloat("\nEnter amount of minutes of energy you want to fill: ");
                    ElectricEngine.FillEnergy(energyAmount);
                    break;
                }
                catch (Exception ex)
                {
                    UserConsole.ExceptionOutput(ex);
                }
            }

            return(energyAmount);
        }
Exemplo n.º 12
0
        internal void FillElectricVehicle()
        {
            while (true)
            {
                try
                {
                    float amountOfEnergy = InputValidation.GetFloat("Enter the amount of minutes of energy to add");
                    r_Garage.FillEnergeVehicle(r_Vehicle.LicenseNumber, amountOfEnergy);
                    break;
                }
                catch (Exception ex)
                {
                    UserConsole.ExceptionOutput(ex);
                    if (ex.Message.Contains("on fuel"))
                    {
                        break;
                    }
                }
            }

            endAction();
        }
Exemplo n.º 13
0
        internal void FillFuelVehicle()
        {
            while (true)
            {
                try
                {
                    FuelEngine.eFuelType fuelTypeInput = (FuelEngine.eFuelType)InputValidation.EnumChoiseToInt(typeof(FuelEngine.eFuelType), UserConsole.ChooseString("fuel type"));
                    float amountOfFuel = InputValidation.GetFloat("Enter the amount of fuel to fill");
                    r_Garage.FillFuelVehicle(r_Vehicle.LicenseNumber, fuelTypeInput, amountOfFuel);
                    break;
                }
                catch (Exception ex)
                {
                    UserConsole.ExceptionOutput(ex);
                    if (ex.Message.Contains("not on fuel!"))
                    {
                        break;
                    }
                }
            }

            endAction();
        }
        private float setFuel(Vehicle i_Vehicle)
        {
            FuelEngine.eFuelType fuelType;
            float fuelAmount = 0;

            while (true)
            {
                try
                {
                    FuelEngine fuelEngine = i_Vehicle.Engine as FuelEngine;
                    UserConsole.Print("\nLets fill up Fuel!");
                    fuelType   = (FuelEngine.eFuelType)InputValidation.EnumChoiseToInt(typeof(FuelEngine.eFuelType), UserConsole.ChooseString("fuel type"));
                    fuelAmount = InputValidation.GetFloat("\nEnter amount of fuel you want to fill: ");
                    fuelEngine.FillFuel(fuelType, fuelAmount);
                    break;
                }
                catch (Exception ex)
                {
                    UserConsole.ExceptionOutput(ex);
                }
            }

            return(fuelAmount);
        }
Exemplo n.º 15
0
        public static void NextStepVehicleMenu(Garage i_Garage, Vehicle i_Vehicle)
        {
            UserConsole   outputUser = new UserConsole();
            int           userChoise;
            string        licenseNumber;
            Vehicle       vehicle;
            VehicleAction vehicleAction = null;
            bool          inputAnswer   = true;

            if (i_Vehicle != null)
            {
                while (true)
                {
                    try
                    {
                        inputAnswer = InputValidation.GetBool("Do you want to switch vehicle?");
                        break;
                    }
                    catch (Exception ex)
                    {
                        UserConsole.ExceptionOutput(ex);
                    }
                }

                if (!inputAnswer)
                {
                    vehicleAction = new VehicleAction(i_Vehicle, i_Garage);
                }
            }

            if (inputAnswer)
            {
                while (true)
                {
                    try
                    {
                        licenseNumber = InputValidation.GetString("Enter License number");
                        vehicle       = i_Garage.GetVehicle(licenseNumber);
                        break;
                    }
                    catch (Exception ex)
                    {
                        UserConsole.ExceptionOutput(ex);
                    }
                }

                vehicleAction = new VehicleAction(vehicle, i_Garage);
            }

            while (true)
            {
                try
                {
                    UserConsole.VehicleMenu();
                    userChoise = InputValidation.GetInt(string.Empty, 1, 6);
                    break;
                }
                catch (Exception ex)
                {
                    UserConsole.ExceptionOutput(ex);
                }
            }

            UserConsole.SleepAndClear();
            switch (userChoise)
            {
            case 1:
                vehicleAction.ChangeVehicleStatus();
                break;

            case 2:
                vehicleAction.FillAirWheels();
                break;

            case 3:
                vehicleAction.FillFuelVehicle();
                break;

            case 4:
                vehicleAction.FillElectricVehicle();
                break;

            case 5:
                vehicleAction.VehicleInfo();
                break;

            case 6:
                NextStepMainMenu(i_Garage);
                break;
            }
        }