예제 #1
0
 internal void                    fillGas(Enums.eFuelType i_FuelType, float i_GasToFill)
 {
     if (i_FuelType == r_FuelType)
     {
         if (i_GasToFill >= 0)
         {
             if (CurrentCapacity + i_GasToFill <= MaxCapacity)
             {
                 CurrentCapacity += i_GasToFill;
             }
             else
             {
                 throw new ValueOutOfRangeException(0, MaxCapacity - CurrentCapacity, "The ammount of gas to fill entered is too high and exceeds the max tank capacity!");
             }
         }
         else
         {
             throw new ArgumentException("The ammount of gas to fill is negative!");
         }
     }
     else
     {
         throw new ArgumentException("Wrong fuel type for vehical!");
     }
 }
예제 #2
0
        private void refuel()
        {
            try
            {
                Enums.eFuelType fuelType       = getEnumValueFromUserByType <Enums.eFuelType>("Select fuel type:");
                float           amountToRefill = getFloatUserInput("Select amount to refuel:");
                string          licensePlate   = getInGarageLicensePlate();

                r_GarageManager.RefillFuel(licensePlate, fuelType, amountToRefill);
                writeSuccessMessage("Vehicle is refueled!");
            }
            catch (ArgumentException i_ArgumentException)
            {
                writeExceptionMessage("One or more of the arguments are wrong.", i_ArgumentException);
            }
        }
예제 #3
0
        public void RefillFuel(string i_LicensePlate, Enums.eFuelType i_FuelType, float i_Amount)
        {
            Vehicle          theVehicle       = getVehicleInGarage(i_LicensePlate);
            FuelEnergySource fuelEnergySource = theVehicle.EnergySource as FuelEnergySource;

            if (fuelEnergySource == null)
            {
                throw new ArgumentException("license plate doesn't belong to fuel vehicle");
            }

            bool isCorrectFuelType = fuelEnergySource.IsCorrectFuelType(i_FuelType);

            if (!isCorrectFuelType)
            {
                throw new ArgumentException("fuel type is incorrect");
            }

            theVehicle.FillEnergy(i_Amount);
        }
예제 #4
0
 public bool IsCorrectFuelType(Enums.eFuelType i_FuelType)
 {
     return(FuelFillingInfo.FuelType == i_FuelType);
 }
예제 #5
0
 public FuelFillingInfo(Enums.eFuelType i_FuelType, float i_MaximumEnergyFillingAmount)
     : base(i_MaximumEnergyFillingAmount)
 {
     r_FuelType = i_FuelType;
 }
예제 #6
0
 public GasEngine(Enums.eFuelType i_FuelType, float i_MaxGasTankCapacity) : base(i_MaxGasTankCapacity)
 {
     r_FuelType = i_FuelType;
 }
예제 #7
0
 public void                                                            RefuelVehical(VehicalInformation i_VehicalToRefuel, Enums.eFuelType i_FuelType, float i_GasToFill)
 {
     if (i_VehicalToRefuel.Vehical.Engine is GasEngine gasVehicalToRefuel)
     {
         gasVehicalToRefuel.fillGas(i_FuelType, i_GasToFill);
     }
     else
     {
         throw new ArgumentException("Cannot refuel a vehical that is not run by gas!");
     }
 }