예제 #1
0
        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.MyFuelType = fuelTypeToSet;

            return(fuelType);
        }
예제 #2
0
        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));
            }
        }
예제 #3
0
        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);
            }
        }
예제 #4
0
 public FuellFillingDetails(FuelType i_FuelType, float i_AmountInLitersToAdd)
 {
     m_FuelType            = i_FuelType;
     m_AmountInLitersToAdd = i_AmountInLitersToAdd;
 }
예제 #5
0
        private float m_CurrentFuelAmountInLiters; // must be initialized with a parameter from ctor

        public FuelSystem(FuelType i_FuelType, float i_MaxFuelAmountInLiters)
        {
            m_FuelType = i_FuelType;
            m_MaxFuelAmountInLiters = i_MaxFuelAmountInLiters;
        }