public static FuelType Parse(string i_FuelTypeAsStr)
        {
            eFuelType fuelTypeToSet = eFuelType.Octan98;

            if (i_FuelTypeAsStr == "2" || i_FuelTypeAsStr == "Octan96" || i_FuelTypeAsStr == "Octan 96" || i_FuelTypeAsStr == "octan96" || i_FuelTypeAsStr == "octan 96" || i_FuelTypeAsStr == "OCTAN96" || i_FuelTypeAsStr == "OCTAN 96")
            {
                fuelTypeToSet = eFuelType.Octan96;
            }
            else if (i_FuelTypeAsStr == "3" || i_FuelTypeAsStr == "Octan95" || i_FuelTypeAsStr == "Octan 95" || i_FuelTypeAsStr == "octan95" || i_FuelTypeAsStr == "octan 95" || i_FuelTypeAsStr == "OCTAN95" || i_FuelTypeAsStr == "OCTAN 95")
            {
                fuelTypeToSet = eFuelType.Octan95;
            }
            else if (i_FuelTypeAsStr == "4" || i_FuelTypeAsStr == "Soler" || i_FuelTypeAsStr == "soler" || i_FuelTypeAsStr == "SOLER")
            {
                fuelTypeToSet = eFuelType.Soler;
            }
            else if (i_FuelTypeAsStr != "1" && i_FuelTypeAsStr != "Octan98" && i_FuelTypeAsStr != "Octan 98" && i_FuelTypeAsStr != "octan98" && i_FuelTypeAsStr != "octan 98" && i_FuelTypeAsStr != "OCTAN98" && i_FuelTypeAsStr != "OCTAN 98")
            {
                throw new FormatException();
            }

            FuelType fuelType = new FuelType();

            fuelType.m_FuelType = fuelTypeToSet;

            return(fuelType);
        }
Exemple #2
0
 public void SupplyEnergy(float i_FuelAmountToSupplyInLiters, FuelType fuelType)
 {
     if (fuelType == this.m_fuelType)
     {
         this.CurrentEnergyStorage += i_FuelAmountToSupplyInLiters;
     }
 }
Exemple #3
0
        public void RefuelVehicle(float i_Quantity, FuelType i_FuelType)
        {
            if (i_FuelType != EnergyType)
            {
                throw new ArgumentException("Inappropriate fuel type");
            }

            Vehicle.RefillIfNotOverflowOrNegativeInput(ref m_CurrentEnergyLevel, i_Quantity, m_MaxEnergyLevel);
        }
        public override List <string> GetEngineDetails(List <string> i_DetailsDictionary)
        {
            i_DetailsDictionary = base.GetEngineDetails(i_DetailsDictionary);
            i_DetailsDictionary.Add(string.Format("Current remaining fuel: {0}", CurrentFuel));
            i_DetailsDictionary.Add(string.Format("Liter fuel tank: {0}", MaxEnergy));
            i_DetailsDictionary.Add(string.Format("Fuel type: {0}", FuelType.ToString()));

            return(i_DetailsDictionary);
        }
Exemple #5
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("The Max Fuel Tank Is The Size Of: " + MaxEnergy + " Litters");
            sb.AppendLine("The Fuel Type is: " + FuelType.ToString());
            sb.AppendLine("The Current Fuel That Left Is " + CurrentEnergy + " Litters");

            return(sb.ToString());
        }
Exemple #6
0
 internal void Refuel(float i_AmountToAdd, FuelType i_FuelType)
 {
     if (i_FuelType.Equals(m_FuelType))
     {
         AddEnergy(i_AmountToAdd);
     }
     else
     {
         throw new ArgumentException("The fuel you're trying to put isn't from the correct type.");
     }
 }
        public override string ToString()
        {
            string fuel = string.Format(
                "Fuel type is {0}, it has {1} amount of gas left out of {2}{3}",
                FuelType.ToString(),
                CurrentFuelTank,
                MaxTank,
                Environment.NewLine);

            return(fuel);
        }
        public void FillFuelInVehicleThatBasedOnFuelSystem(string i_LicenseNum, FuelType i_FuelType, float i_FillingAmount)
        {
            Dictionary <string, Vehicle> collectionWhereVehicleStored = DetectCollectionInWhichTheVehicleStored(i_LicenseNum);

            if (collectionWhereVehicleStored == null)
            {
                throw new ArgumentException();
            }
            else
            {
                collectionWhereVehicleStored[i_LicenseNum].FillEnergy(new FuelSystem.FuellFillingDetails(i_FuelType, i_FillingAmount));
            }
        }
Exemple #9
0
        public void CheckingFuelTypeInput(string i_LicenseNumberToReful, string i_FuelType)
        {
            Vehicle vehicleToCheck;

            m_VehicleInTheGarage.TryGetValue(i_LicenseNumberToReful.GetHashCode(), out vehicleToCheck);
            if (vehicleToCheck.EnergySource is FuelTank)
            {
                FuelTank           FuelTankTochek = vehicleToCheck.EnergySource as FuelTank;
                FuelType.eFuelType fuelTypeToFill = FuelType.ParseFromString(i_FuelType);
                if (FuelTankTochek._FuelType != fuelTypeToFill)
                {
                    throw new ArgumentException(string.Format("The vehicle with the license number {0} does not support {1} fuel type.", i_LicenseNumberToReful, fuelTypeToFill.ToString()));
                }
            }
        }
        public static PropulsionSystem CreatePropulsionSystem(string i_VehicleName, string i_PropulsionSystem)
        {
            try
            {
                PropulsionSystem newPropulsionSystem = null;

                if (i_PropulsionSystem == "1" || i_PropulsionSystem == "FuelSystem" || i_PropulsionSystem == "Fuel System")
                {
                    if (i_VehicleName == "Car")
                    {
                        newPropulsionSystem = new FuelSystem(FuelType.Parse("Octan98"), 42f);
                    }
                    else if (i_VehicleName == "Motorcycle")
                    {
                        newPropulsionSystem = new FuelSystem(FuelType.Parse("Octan95"), 5.5f);
                    }
                    else if (i_VehicleName == "Truck")
                    {
                        newPropulsionSystem = new FuelSystem(FuelType.Parse("Octan96"), 135f);
                    }
                }
                else if (i_PropulsionSystem == "2" || i_PropulsionSystem == "ElectricSystem" || i_PropulsionSystem == "Electric System")
                {
                    if (i_VehicleName == "Car")
                    {
                        newPropulsionSystem = new ElectricSystem(2.5f);
                    }
                    else if (i_VehicleName == "Motorcycle")
                    {
                        newPropulsionSystem = new ElectricSystem(2.7f);
                    }
                    else if (i_VehicleName == "Truck")
                    {
                        throw new FormatException();
                    }
                }
                else
                {
                    throw new ArgumentException();
                }

                return(newPropulsionSystem);
            }
            catch (FormatException exception)
            {
                throw new ValueOutOfRangeException(exception, 1, 1);
            }
        }
Exemple #11
0
     public override string ToString()
     {
         return(string.Format(
                    @"Model Name: {0} 
 Car Color: {1}
 Num Of Doors: {2}
 Fuel Type: {3}
 Current Fuel Amount: {4}
 Maximum Fuel Capacity: {5}
 {6}",
                    Model,
                    CarDetails.VehicleColor.ToString(),
                    CarDetails.NumOfDoors.GetHashCode(),
                    FuelType.ToString(),
                    Energy.CurrentEnergy,
                    Energy.MaxEnergy,
                    Wheels[0].ToString()));
     }
Exemple #12
0
     public override string ToString()
     {
         return(string.Format(
                    @"Model Name: {0} 
 Is Transporting Dangerous Material: {1}
 Cargo Capacity: {2}
 Fuel Type: {3}
 Current Fuel Amount: {4}
 Maximum Fuel Capacity: {5}
 {6}",
                    Model,
                    m_IsTransportingDangerousMaterial.ToString(),
                    m_CargoCapacity,
                    FuelType.ToString(),
                    Energy.CurrentEnergy,
                    Energy.MaxEnergy,
                    Wheels[0].ToString()));
     }
Exemple #13
0
     public override string ToString()
     {
         return(string.Format(
                    @"Model Name: {0} 
 Lisence Type: {1}
 Engine Capacity: {2}
 Fuel Type: {3}
 Current Fuel Amount: {4}
 Maximum Fuel Capacity: {5}
 {6}",
                    Model,
                    MotorcycleDetails.LicenseType.ToString(),
                    MotorcycleDetails.EngineCapacity,
                    FuelType.ToString(),
                    Energy.CurrentEnergy,
                    Energy.MaxEnergy,
                    Wheels[0].ToString()));
     }
Exemple #14
0
        public string RefuelingAVehicle(string i_LicenseNumberToReful, string i_FuelType, string i_AmountOfLitersToAdd)
        {
            string  loadMessage;
            Vehicle vehicleToLoad;

            m_VehicleInTheGarage.TryGetValue(i_LicenseNumberToReful.GetHashCode(), out vehicleToLoad);

            if (vehicleToLoad.EnergySource is FuelTank)
            {
                FuelTank currentVehicleFuelTank = vehicleToLoad.EnergySource as FuelTank;
                currentVehicleFuelTank.Refueling(float.Parse(i_AmountOfLitersToAdd), FuelType.ParseFromString(i_FuelType));///check EXP caching
                loadMessage = string.Format("The vehicle {0} refueling was successful.", i_LicenseNumberToReful);
            }
            else
            {
                throw new ArgumentException(string.Format("The vehicle with the license number: {0} is electric vehicle.", i_LicenseNumberToReful));
            }

            updatePrecentOfenergy(i_LicenseNumberToReful, i_AmountOfLitersToAdd);

            return(loadMessage);
        }
Exemple #15
0
        public string EngineData(FuelType i_Energy)
        {
            string engineDescription;

            if (i_Energy.Equals(FuelType.Electricity))
            {
                engineDescription = string.Format(@"
            Current Battery Level : {0}
            Maximum Time For Battery(in hours) : {1}
            ", Engine.CurrentEnergyLevel, Engine.MaxEnergyLevel);
            }

            else
            {
                engineDescription = string.Format(@"
                Kind of fuel : {0}
                Gasoline level for now : {1}
                Maximum gasoline level : {2}
                ", Engine.EnergyType, Engine.CurrentEnergyLevel, Engine.MaxEnergyLevel);
            }

            return(engineDescription);
        }
Exemple #16
0
 public Engine(FuelType i_KindOfFuel, float i_CurrentEnergyLevel, float i_MaxEnergyLevel)
 {
     EnergyType         = i_KindOfFuel;
     MaxEnergyLevel     = i_MaxEnergyLevel;
     CurrentEnergyLevel = i_CurrentEnergyLevel;
 }
Exemple #17
0
 public FuelSystem(FuelType i_FuelType, float i_MaximumAmountOfFuelInLiters, float i_AmountOfCurrentFuelInLiters) :
     base(i_AmountOfCurrentFuelInLiters, i_MaximumAmountOfFuelInLiters)
 {
     this.m_fuelType = i_FuelType;
 }
 public FuellFillingDetails(FuelType i_FuelType, float i_AmountInLitersToAdd)
 {
     m_FuelType            = i_FuelType;
     m_AmountInLitersToAdd = i_AmountInLitersToAdd;
 }
        private float m_CurrentFuelAmountInLiters; // must initialized with a parameter from ctor

        public FuelSystem(FuelType i_FuelType, float i_MaxFuelAmountInLiters)
        {
            m_FuelType = i_FuelType;
            m_MaxFuelAmountInLiters = i_MaxFuelAmountInLiters;
        }
Exemple #20
0
 internal Fuel(Dictionary <string, string> i_VehicleProperties)
     : base(i_VehicleProperties)
 {
     m_FuelType = FieldsChecker.CheckValidFuelType(i_VehicleProperties["Fuel type"]);
 }