Exemplo n.º 1
0
        public void AddFuelToVehicle(string i_PlateNumber, float i_FuelAmount, FuelVehicle.eFuelType i_FuelType)
        {
            FuelVehicle fuelVehicle = null;

            foreach (KeyValuePair <Vehicle, Owner> vehicle in m_VehiclesInGarage)
            {
                if (vehicle.Key.LicensePlateNumber == i_PlateNumber)
                {
                    fuelVehicle = vehicle.Key as FuelVehicle;

                    if (fuelVehicle == null)
                    {
                        throw new ArgumentException("This vehicle does not match this type of operation");
                    }
                    else
                    {
                        fuelVehicle.AddFuel(i_FuelAmount, i_FuelType);
                        break;
                    }
                }
            }

            if (fuelVehicle == null)
            {
                throw new ArgumentException(string.Format("Vehicle with this license plates does not exists in the Garage"));
            }
        }
Exemplo n.º 2
0
        public void Refuel(string i_LicensePlateNumber, float i_HowMuchToFill, eFuelTypes i_FuelType)
        {
            int vehicleLocation = CheckIfVehicleInGarage(i_LicensePlateNumber);

            if (vehicleLocation == k_NotInGarage)
            {
                throw new ArgumentException("Vehicle is NOT in garage");
            }

            FuelVehicle customerVehicle = r_AllVehiclesInGarage[vehicleLocation] as FuelVehicle;

            if (customerVehicle == null)
            {
                throw new ArgumentException("NOT a fuel vehicle");
            }

            float newFuelLeft = customerVehicle.FuelLeft + i_HowMuchToFill;
            float calculatedMaximumFuelCapacity = customerVehicle.MaxFuelTankCapacity - customerVehicle.FuelLeft;

            if (newFuelLeft > customerVehicle.MaxFuelTankCapacity)
            {
                throw new ValueOutOfRangeException(calculatedMaximumFuelCapacity, k_MininumRangeValue);
            }

            if (i_FuelType != customerVehicle.FuelType)
            {
                throw new ArgumentException("fuel type is NOT valid");
            }

            customerVehicle.FuelLeft = newFuelLeft;
        }
Exemplo n.º 3
0
        public override List <VehicleParam> GetNewVehicleParams()
        {
            List <VehicleParam> parmatersList = new List <VehicleParam>();

            parmatersList.AddRange(Vehicle.GetParams());
            parmatersList.AddRange(FuelVehicle.GetParams());
            parmatersList.AddRange(Bike.GetParams());
            return(parmatersList);
        }
Exemplo n.º 4
0
        public void RefuelEnergy(eFuel i_FuelType, float i_FuelAmountToAdd)
        {
            FuelVehicle vehicle = this as FuelVehicle;

            if (vehicle != null)
            {
                vehicle.Refuel(i_FuelAmountToAdd, i_FuelType);
                updateLeftedEnergyPrecent(vehicle.Energy);
            }
        }
Exemplo n.º 5
0
 //// Driving on fuel
 public Car(eVehicleColor i_eVehicleColor, string i_ModelName, string i_LicenseNumber, float i_PercentageOfVehicleEnergy, float i_CurrentFuel, string i_WheelsManufacturerName, float i_WheelsCurrentAirPressure)
     : base(i_ModelName, i_LicenseNumber, i_PercentageOfVehicleEnergy)
 {
     this.m_eColor           = i_eVehicleColor;
     this.m_eQuantityOfDoors = eQuantityOfDoors.Four;
     FuelVehicle.eFueltType eFueltType = FuelVehicle.eFueltType.Octan96;
     this.m_MaxFuelOrMaxTimeBattery = 55f;
     VehicleDrivingOnFuel           = new FuelVehicle(i_CurrentFuel, m_MaxFuelOrMaxTimeBattery, eFueltType);
     Wheels  = new Wheel(i_WheelsManufacturerName, i_WheelsCurrentAirPressure, 31, 4);
     m_fuelt = ", fuelt type: " + eFueltType;
 }
Exemplo n.º 6
0
 /// Driving on fuel
 public Motorcycle(eLicenseType i_eLicense, int i_EngineCapacityIncc, string i_ModelName, string i_LicenseNumber, float i_PercentageOfVehicleEnergy, float i_CurrentFuel, string i_WheelsManufacturerName, float i_WheelsCurrentAirPressure)
     : base(i_ModelName, i_LicenseNumber, i_PercentageOfVehicleEnergy)
 {
     this.m_eLicense         = i_eLicense;
     this.EngineCapacityIncc = i_EngineCapacityIncc;
     this.m_MaxFuelOrElectic = 8f;
     FuelVehicle.eFueltType eFueltType = FuelVehicle.eFueltType.Octan95;
     VehicleDrivingOnFuel = new FuelVehicle(i_CurrentFuel, m_MaxFuelOrElectic, eFueltType);
     Wheels  = new Wheel(i_WheelsManufacturerName, i_WheelsCurrentAirPressure, 33, 2);
     m_fuelt = ", fuelt type: " + eFueltType;
 }
 public Truck(bool i_IsDrivingDangerousMaterials, float i_VolumeOfCargo, string i_ModelName, string i_LicenseNumber, float i_PercentageOfVehicleEnergy, float i_CurrentFuel, string i_WheelsManufacturerName, float i_WheelsCurrentAirPressure)
     : base(i_ModelName, i_LicenseNumber, i_PercentageOfVehicleEnergy)
 {
     this.m_IsDrivingDangerousMaterials = i_IsDrivingDangerousMaterials;
     this.m_VolumeOfCargo = i_VolumeOfCargo;
     FuelVehicle.eFueltType eFueltType = FuelVehicle.eFueltType.Soler;
     m_MaxFuel            = 110f;
     VehicleDrivingOnFuel = new FuelVehicle(i_CurrentFuel, m_MaxFuel, eFueltType);
     Wheels  = new Wheel(i_WheelsManufacturerName, i_WheelsCurrentAirPressure, 26, 12);
     m_fuelt = ", fuelt type: " + eFueltType;
 }
Exemplo n.º 8
0
        public static new List <string> GetQuestions()
        {
            List <string> questionsToUserFuelVehicle = FuelVehicle.GetQuestions();
            List <string> questionsToUserCar         = Car.GetQuestions();

            foreach (string str in questionsToUserCar)
            {
                questionsToUserFuelVehicle.Add(str);
            }

            return(questionsToUserFuelVehicle);
        }
Exemplo n.º 9
0
        public static new List <string> GetAtributes()
        {
            List <string> getAtributesFuelVehicle = FuelVehicle.GetAtributes();
            List <string> getAtributesUserCar     = Car.GetAtributes();

            foreach (string str in getAtributesUserCar)
            {
                getAtributesFuelVehicle.Add(str);
            }

            return(getAtributesFuelVehicle);
        }
Exemplo n.º 10
0
        internal static new List <string> GetAtributes()
        {
            List <string> atributesFuelVehicle = FuelVehicle.GetAtributes();
            List <string> atributesToUserCar   = Car.GetAtributes();

            foreach (string str in atributesToUserCar)
            {
                atributesFuelVehicle.Add(str);
            }

            atributesFuelVehicle.Add("IsCarryDangerousMaterial");
            atributesFuelVehicle.Add("CarryVolume");
            return(atributesFuelVehicle);
        }
Exemplo n.º 11
0
        internal static new List <string> GetQuestions()
        {
            List <string> questionsToUserFuelVehicle = FuelVehicle.GetQuestions();
            List <string> questionsToUserCar         = Car.GetQuestions();

            foreach (string str in questionsToUserCar)
            {
                questionsToUserFuelVehicle.Add(str);
            }

            questionsToUserFuelVehicle.Add("Please enter true if the truck carry dangerous material, or false if doesn't");
            questionsToUserFuelVehicle.Add("Please enter the carry volume of the truck");
            return(questionsToUserFuelVehicle);
        }
Exemplo n.º 12
0
        //5. Refuel a fuel-based vehicle (Prompting the user for the license number, fuel type and amount to fill)
        public void RefuelVehicle(string i_LicenseNumber, eEnergyType i_FuelType, float i_FuelToAdd)
        {
            FuelVehicle vehilceToRefuel = (FuelVehicle)GetVehicleByLicense(i_LicenseNumber);

            if (vehilceToRefuel.EnergyType == i_FuelType)
            {
                if (vehilceToRefuel.CurrentFuelLevel >= vehilceToRefuel.MaximalFuelLevel)
                {
                    throw new ValueOutOfRangeException(vehilceToRefuel.MaximalFuelLevel, 0, "Tank is already full");
                }

                float currentLevel = vehilceToRefuel.AddEnergy(vehilceToRefuel, vehilceToRefuel.MaximalFuelLevel, vehilceToRefuel.CurrentFuelLevel, i_FuelToAdd);
                vehilceToRefuel.CurrentFuelLevel = currentLevel;
            }
            else
            {
                throw new ArgumentException("Wrong Type of Fuel.");
            }
        }
Exemplo n.º 13
0
 public void FillInEnergyToVehicle(
     string i_LicenseNumber,
     float i_AmountToAdd,
     out bool o_IsSucceeded,
     FuelVehicle.eFuelType?i_FuelType = null)
 {
     try
     {
         o_IsSucceeded = false;
         bool isExist = r_VehicleList.TryGetValue(i_LicenseNumber, out VehicleInShop toRefuel);
         if (isExist)
         {
             if (toRefuel.m_VehicleInShop is FuelVehicle && i_FuelType != null)
             {
                 FuelVehicle fuelVehicle = toRefuel.m_VehicleInShop as FuelVehicle;
                 if (fuelVehicle != null)
                 {
                     fuelVehicle.Refueling(i_AmountToAdd, (FuelVehicle.eFuelType)i_FuelType);
                     o_IsSucceeded = true;
                 }
             }
             else if (toRefuel.m_VehicleInShop is ElectricVehicle)
             {
                 ElectricVehicle electricVehicle = toRefuel.m_VehicleInShop as ElectricVehicle;
                 if (electricVehicle != null)
                 {
                     electricVehicle.Loading(i_AmountToAdd / 60);
                     o_IsSucceeded = true;
                 }
             }
         }
         else
         {
             o_IsSucceeded = false;
             throw new ArgumentException(k_IsNotExistError);
         }
     }
     catch (Exception ex)
     {
         throw new Exception("Fail to fill in the energy in the vehicle", ex);
     }
 }
Exemplo n.º 14
0
        public void RefuelVehicleEnergy(string i_LicenseNumber, int i_FuelType, float i_FuelAmountToAdd)
        {
            eFuel fuelType;

            if (IsExistInGarage(i_LicenseNumber))
            {
                FuelVehicle fuelVehicle = m_VehiclesInGarage[i_LicenseNumber].Vehicle as FuelVehicle;
                if (fuelVehicle != null)
                {
                    fuelType = checkIfValidFuelParam(i_FuelType);
                    m_VehiclesInGarage[i_LicenseNumber].Vehicle.RefuelEnergy(fuelType, i_FuelAmountToAdd);
                }
                else
                {
                    throw new ArgumentException(string.Format("Vehicle with license number '{0}' is not a Fuel Vehicle", i_LicenseNumber));
                }
            }
            else
            {
                throw new ArgumentException(string.Format("Vehicle with license number '{0}' is not exist in the garage", i_LicenseNumber));
            }
        }
Exemplo n.º 15
0
 public bool IsFuelType(Vehicle i_Vehicle, out FuelVehicle o_FuelVehicleToReturn)
 {
     o_FuelVehicleToReturn = i_Vehicle as FuelVehicle;
     return(i_Vehicle is FuelVehicle);
 }
Exemplo n.º 16
0
        public bool IsFuelFit(FuelVehicle.eFuel i_Fuel, Vehicle i_Vehicle)
        {
            FuelVehicle fuelVehicle = i_Vehicle as FuelVehicle;

            return(fuelVehicle.Fuel == i_Fuel);
        }
Exemplo n.º 17
0
 public void FillFuel(FuelVehicle i_FuelVehicle, FuelVehicle.eFuel i_Fuel, float i_HowMuchToFill)
 {
     i_FuelVehicle.FillFuel(i_Fuel, i_HowMuchToFill);
 }
Exemplo n.º 18
0
 public bool CanAddFuel(float i_AmountOfFuelToAdd, FuelVehicle i_FuelVehicle, out float o_MaxAmountPossibleToAdd)
 {
     return(i_FuelVehicle.CheckAddFuel(i_AmountOfFuelToAdd, out o_MaxAmountPossibleToAdd));
 }
Exemplo n.º 19
0
 public bool IfFuelFits(FuelVehicle i_FuelVehicle, FuelVehicle.eFuel i_Fuel, out FuelVehicle.eFuel o_CorrectFuelType)
 {
     o_CorrectFuelType = i_FuelVehicle.Fuel;
     return(i_FuelVehicle.Fuel == i_Fuel);
 }