예제 #1
0
파일: GasEngine.cs 프로젝트: zvaigen/Garage
 public void Refuel(float i_AddGas, Vehicle.eGasTypes i_GasType)
 {
     if (i_AddGas + m_CurrentGasAmount <= m_MaximumGasAmount && m_GasType == i_GasType)
     {
         m_CurrentGasAmount += i_AddGas;
     }
     else
     {
         throw new ValueOutOfRangeException(0, m_MaximumGasAmount);
     }
 }
예제 #2
0
파일: GasEngine.cs 프로젝트: zvaigen/Garage
        public GasEngine(Vehicle.eGasTypes i_GasType, float i_CurrentGasAmount, float i_MaximumGasAmount)
        {
            float currEnergy = i_CurrentGasAmount;

            if (currEnergy > i_MaximumGasAmount || currEnergy < 0)
            {
                throw new ArgumentException(string.Format("Wheel's air pressure must be between {0} to {1}", 0, i_MaximumGasAmount));
            }
            else
            {
                this.m_CurrentGasAmount = currEnergy;
            }

            this.GasType            = i_GasType;
            this.m_MaximumGasAmount = i_MaximumGasAmount;
        }
예제 #3
0
파일: Garage.cs 프로젝트: zvaigen/Garage
        public void VehicleGasRefule(string i_LicenseNumber, Vehicle.eGasTypes i_GasType, float i_GasAmount)
        {
            VehiclesInTheGarage currentVehicleInTheGarage = null;

            if (m_VehiclesInTheGarage.TryGetValue(i_LicenseNumber, out currentVehicleInTheGarage))
            {
                GasEngine gasVehicle = currentVehicleInTheGarage.Vehicle.Engine as GasEngine;

                if (gasVehicle != null)
                {
                    gasVehicle.Refuel(i_GasAmount, i_GasType);
                }
                else
                {
                    throw new ArgumentException("This vehicle needs a different fuel type.");
                }
            }
            else
            {
                throw new ArgumentException("The vehicle is not in the garage.");
            }
        }
예제 #4
0
        /// <summary>
        /// Option5
        /// </summary>
        private void refuelVehicle()
        {
            Console.WriteLine();
            string license       = inputFromUser("Insert license number:");
            string chooseGasType = string.Format(
                @"Choose gas type:
1) Soler.  
2) Octan95.
3) Octan96.
4) Octan98.");

            Console.WriteLine(chooseGasType);
            if (m_Garage.IsCarInTheGarage(license))
            {
                Vehicle.eGasTypes gasType = (Vehicle.eGasTypes)inputFromUserAndCheckIfInRangeInt(1, 4);
                Console.WriteLine("Insert gas amount:");
                float gasAmount = inputFromUserAndCheckIfInRangeFloat(0, 135.0f);
                m_Garage.VehicleGasRefule(license, gasType, gasAmount);
            }
            else
            {
                throw new ArgumentException("The vehicle is not in the garage");
            }
        }