Ejemplo n.º 1
0
        public static float GetAirPressure(VehicleCreator.eVehicleType i_VehicleType, VehicleCreator.ePowerType i_EnergyType)
        {
            bool  askAgain     = true;
            float maxAir       = GetMaxAir(i_VehicleType, i_EnergyType);
            float inputInFloat = 0;

            while (askAgain == true)
            {
                Console.WriteLine("Please enter current air pressure");
                string inputFromUser = Console.ReadLine();

                if (float.TryParse(inputFromUser, out inputInFloat))
                {
                    if (inputInFloat <= maxAir)
                    {
                        askAgain = false;
                    }

                    else
                    {
                        Console.WriteLine("The value you entered is too big please try again");
                    }
                }

                else
                {
                    Console.WriteLine("Wrong input please try again");
                }
            }

            return(inputInFloat);
        }
Ejemplo n.º 2
0
        public static float GetAmountOfPowerSource(VehicleCreator.eVehicleType i_VehicleType, VehicleCreator.ePowerType i_EnergyType)
        {
            bool  askAgain     = true;
            float maxPower     = GetMaxPower(i_VehicleType, i_EnergyType);
            float inputInFloat = 0;

            while (askAgain == true)
            {
                Console.WriteLine(@"How much power is your vehicle left? ");
                string inputFromUser = Console.ReadLine();

                if (float.TryParse(inputFromUser, out inputInFloat))
                {
                    if (inputInFloat <= maxPower)
                    {
                        askAgain = false;
                    }

                    else
                    {
                        Console.WriteLine("The value you entered is too big please try again");
                    }
                }

                else
                {
                    Console.WriteLine("Wrong input please try again");
                }
            }

            return(inputInFloat);
        }
Ejemplo n.º 3
0
        private void reciveVehicleType(out VehicleCreator.eVehicleType o_UserChoice)
        {
            Console.WriteLine("Please choose a vehicle type from the list below by selecting the number on the right:");
            try
            {
                int  inputAsInt;
                bool isValid = false;
                do
                {
                    printVehicleOptions();
                    string inputAsString = Console.ReadLine();
                    inputAsInt = int.Parse(inputAsString);
                    isValid    = Enum.IsDefined(typeof(VehicleCreator.eVehicleType), inputAsInt);
                    if (isValid == false)
                    {
                        Console.WriteLine(@"Value not in range!
Please choose a vehicle type from the list below by selecting the number on the right:");
                    }
                } while (isValid == false);

                o_UserChoice = (VehicleCreator.eVehicleType)inputAsInt;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                reciveVehicleType(out o_UserChoice);
            }
        }
Ejemplo n.º 4
0
 public void AddNewVehicleToGarage(string i_LicenseNumber, VehicleCreator.eVehicleType i_VehicleType)
 {
     if (r_Vehicles.ContainsKey(i_LicenseNumber))
     {
         r_Vehicles[i_LicenseNumber].VehicleStatus = Vehicle.eVehicleStatus.InRepair;
     }
     else
     {
         Vehicle newVehicle = VehicleCreator.CreateVehicle(i_LicenseNumber, i_VehicleType);
         r_Vehicles.Add(i_LicenseNumber, newVehicle);
         if (newVehicle.Engine is FuelEngine)
         {
             m_NumberOfFuelVehicles++;
         }
         else
         {
             m_NumberOfElectricVehicles++;
         }
     }
 }
Ejemplo n.º 5
0
        public static float GetMaxAir(VehicleCreator.eVehicleType i_VehicleType, VehicleCreator.ePowerType i_EnergyType)
        {
            float maxAir = 0;

            switch (i_VehicleType)
            {
            case VehicleCreator.eVehicleType.Car:
                maxAir = 32f;
                break;

            case VehicleCreator.eVehicleType.Motorcycle:
                maxAir = 28f;

                break;

            case VehicleCreator.eVehicleType.Truck:
                maxAir = 30f;
                break;
            }

            return(maxAir);
        }
Ejemplo n.º 6
0
        public static float GetMaxPower(VehicleCreator.eVehicleType i_VehicleType, VehicleCreator.ePowerType i_EnergyType)
        {
            float maxPower = 0;

            switch (i_VehicleType)
            {
            case VehicleCreator.eVehicleType.Car:
                if (i_EnergyType == VehicleCreator.ePowerType.Gas)
                {
                    maxPower = 50f;
                }
                else
                {
                    maxPower = 1.6f;
                }
                break;

            case VehicleCreator.eVehicleType.Motorcycle:
                if (i_EnergyType == VehicleCreator.ePowerType.Gas)
                {
                    maxPower = 5.5f;
                }
                else
                {
                    maxPower = 4.8f;
                }

                break;

            case VehicleCreator.eVehicleType.Truck:
                maxPower = 105f;
                break;
            }

            return(maxPower);
        }