Beispiel #1
0
        public static Car CreateCar(Energy i_Energy, Wheel[] i_Wheels, string i_LicenseNumber, string i_ModelName,
                                    eCarColor i_CarColor, eNumberOfDoors i_NumberOfDoors)
        {
            Car             newCar          = null;
            ElectricEnergy  electricEnergy  = i_Energy as ElectricEnergy;
            FuelBasedEnergy fuelBasedEnergy = i_Energy as FuelBasedEnergy;
            eVehicleType    vehicleType     = eVehicleType.Electric;

            if (electricEnergy != null)
            {
                isElectricCarParamsAreValid(i_Wheels, electricEnergy.MaxBatteryTime);
            }
            else if (fuelBasedEnergy != null)
            {
                isFuelBasedCarParamsAreValid(i_Wheels, fuelBasedEnergy.FuelType, fuelBasedEnergy.MaxFuelAmount);
                vehicleType = eVehicleType.FuelBased;
            }
            else
            {
                throw new ArgumentException("Not a valid Vehicle! Should be fuel based or electric based only.");
            }

            newCar = new Car(i_Energy, i_Wheels, i_CarColor, i_NumberOfDoors, i_ModelName, i_LicenseNumber, vehicleType);

            return(newCar);
        }
Beispiel #2
0
        public static Motorcycle CreateMotorcycle(Energy i_Energy, Wheel[] i_Wheels, string i_LicenseNumber, string i_ModelName,
                                                  eLicenseType i_LicenseType, int i_EngineVolume)
        {
            Motorcycle      newMotorcycle   = null;
            ElectricEnergy  electricEnergy  = i_Energy as ElectricEnergy;
            FuelBasedEnergy fuelBasedEnergy = i_Energy as FuelBasedEnergy;
            eVehicleType    vehicleType     = eVehicleType.Electric;

            if (electricEnergy != null)
            {
                isElectricMotorcycleParamsAreValid(i_Wheels, electricEnergy.MaxBatteryTime);
            }
            else if (fuelBasedEnergy != null)
            {
                isFuelBasedMotorcycleParamsAreValid(i_Wheels, fuelBasedEnergy.FuelType, fuelBasedEnergy.MaxFuelAmount);
                vehicleType = eVehicleType.FuelBased;
            }
            else
            {
                throw new ArgumentException("Not a valid Energy!");
            }

            newMotorcycle = new Motorcycle(i_Energy, i_Wheels, i_LicenseNumber, i_LicenseType, i_EngineVolume, i_ModelName, vehicleType);

            return(newMotorcycle);
        }
Beispiel #3
0
 public Truck(FuelBasedEnergy i_FuelEnergy, Wheel[] i_Wheels, bool i_ContainDangerousMaterials,
              float i_CargoVolume, string i_ModelName, string i_LicenseNumber)
     : base(i_ModelName, i_LicenseNumber, i_Wheels, i_FuelEnergy, eVehicleType.FuelBased)
 {
     m_ContainDangerousMaterials = i_ContainDangerousMaterials;
     m_CargoVolume = i_CargoVolume;
 }
Beispiel #4
0
        public static Truck CreateTruck(FuelBasedEnergy i_FuelBasedTruck, Wheel[] i_Wheels, string i_LicenseNumber, string i_ModelName,
                                        bool i_ContainDangerousMaterials, float i_CargoVolume)
        {
            Truck newTruck = null;

            isFuelBasedTruckParamsAreValid(i_Wheels, i_FuelBasedTruck.FuelType, i_FuelBasedTruck.MaxFuelAmount);
            newTruck = new Truck(i_FuelBasedTruck, i_Wheels, i_ContainDangerousMaterials, i_CargoVolume, i_ModelName, i_LicenseNumber);

            return(newTruck);
        }
Beispiel #5
0
        public static FuelBasedEnergy CreateFuelBasedEnergy(eFuelType i_FuelType, float i_MaxFuelAmount, float i_CurrentFuelAmount)
        {
            if (i_MaxFuelAmount < i_CurrentFuelAmount)
            {
                throw new ValueOutOfRangeException(i_CurrentFuelAmount, i_MaxFuelAmount, 0.0f);
            }

            FuelBasedEnergy fuelEnergy = new FuelBasedEnergy(i_FuelType, i_MaxFuelAmount, i_CurrentFuelAmount);

            return(fuelEnergy);
        }
Beispiel #6
0
        public void FuelGas(float i_GasAmount, eFuelType i_FuelType)
        {
            FuelBasedEnergy energy = m_Energy as FuelBasedEnergy;

            if (energy == null)
            {
                throw new ArgumentException("This morotcycle is not fuel based!");
            }

            energy.FuelGas(i_GasAmount, i_FuelType);;
        }
Beispiel #7
0
        public static void RefuelFuelBasedVehicle(string i_VehicleLicensePlate, eFuelType i_FuelType, float i_AmountToFuel)
        {
            Vehicle         vehicle      = getVehicleByLicensePlate(i_VehicleLicensePlate);
            FuelBasedEnergy EnergyToFuel = vehicle.Energy as FuelBasedEnergy;

            if (EnergyToFuel == null)
            {
                throw new ArgumentException("Only Fuel Based Vehicles are accepted.");
            }

            EnergyToFuel.FuelGas(i_AmountToFuel, i_FuelType);
        }
Beispiel #8
0
        public void FuelGas(float i_GasAmount, eFuelType i_FuelType)
        {
            FuelBasedEnergy enegry = m_Energy as FuelBasedEnergy;

            enegry.FuelGas(i_GasAmount, i_FuelType);
        }