Пример #1
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);
        }
Пример #2
0
        private static EnergySource getEnergySource(
            string i_EnergySource,
            string i_VehicleType,
            Dictionary <string, string> i_VehicleProperties)
        {
            EnergySource energySource;
            float        maxEnergy;
            float        energyLeft;
            float        minEnergyToAdd   = 0;
            float        energyPercenatge = float.Parse(i_VehicleProperties["Energy Percentage (number 0-100)"]);

            energyPercenatge /= 100;
            if (i_EnergySource == "Fuel")
            {
                eFuelType fuelType = getFuelType(i_VehicleType);
                maxEnergy    = getFuelMaxEnergy(i_VehicleType);
                energyLeft   = maxEnergy * energyPercenatge;
                energySource = new FuelEnergy(fuelType, maxEnergy, energyLeft, minEnergyToAdd);
            }
            else if (i_EnergySource == "Electric")
            {
                maxEnergy    = getElectricMaxEnergy(i_VehicleType);
                energyLeft   = maxEnergy * energyPercenatge;
                energySource = new ElectricEnergy(maxEnergy, energyLeft, minEnergyToAdd);
            }
            else
            {
                throw new Exception("energy source is not valid");
            }

            return(energySource);
        }
Пример #3
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);
        }
Пример #4
0
        public static ElectricEnergy CreateElectricEnergy(float i_MaxBatteryTimeAmount, float i_CurrentBatteryTimeAmount)
        {
            if (i_MaxBatteryTimeAmount < i_CurrentBatteryTimeAmount)
            {
                throw new ValueOutOfRangeException(i_CurrentBatteryTimeAmount, i_MaxBatteryTimeAmount, 0.0f);
            }

            ElectricEnergy electricEnergy = new ElectricEnergy(i_MaxBatteryTimeAmount, i_CurrentBatteryTimeAmount);

            return(electricEnergy);
        }
Пример #5
0
        public void RechargeElectricVehicle(string i_LicensePlate, float i_MinutesToAdd)
        {
            this.checkLicensePlate(i_LicensePlate);
            ElectricEnergy currentEnergy = this.m_Vehicle[i_LicensePlate].Vehicle.Energy as ElectricEnergy;

            if (currentEnergy == null)
            {
                throw new ArgumentException("Vehicle doesn't have electric type energy!");
            }

            currentEnergy.Charge(i_MinutesToAdd);
        }
Пример #6
0
        public static void ChargeVehicle(string i_VehicleLicensePlate, float i_AmountToCharge)
        {
            Vehicle vehicle = getVehicleByLicensePlate(i_VehicleLicensePlate);

            ElectricEnergy EnergyToCharge = vehicle.Energy as ElectricEnergy;

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

            EnergyToCharge.ChargeBattery(i_AmountToCharge);
        }
Пример #7
0
        public void ChargeBattery(float i_ChargingTime)
        {
            ElectricEnergy energy = m_Energy as ElectricEnergy;

            if (energy != null)
            {
                energy.ChargeBattery(i_ChargingTime);
            }
            else
            {
                throw new ArgumentException("This motorcycle is not electric!");
            }
        }
Пример #8
0
 public void ChargeBattery(string i_LicensePlate, float i_AmountOfChargeBatteryToDo)
 {
     if (m_VehicleTickets[i_LicensePlate].Vehicle.EnergySource is ElectricEnergy)
     {
         ElectricEnergy CarBattery = m_VehicleTickets[i_LicensePlate].Vehicle.EnergySource as ElectricEnergy;
         try
         {
             CarBattery.AddEnergy(i_AmountOfChargeBatteryToDo);
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex.Message);
             throw ex;
         }
     }
     else
     {
         throw new FormatException("Vehicle is not using electricity!");
     }
 }
Пример #9
0
        public static Vehicle CreateVehicle(string i_LicensePlate, eVehicleType i_VehicleType)
        {
            Vehicle newVehicle = null;
            Energy  energyType = null;

            if (i_VehicleType == eVehicleType.FuelCar)
            {
                energyType = new FuelEnergy(FuelEnergy.eFuelType.Octan98, k_FuelCarMaxEnergyCapacity);
                newVehicle = new Car(i_LicensePlate, energyType);
            }
            else if (i_VehicleType == eVehicleType.ElectricCar)
            {
                energyType = new ElectricEnergy(k_ElectricCarMaxEnergyCapacity);
                newVehicle = new Car(i_LicensePlate, energyType);
            }
            else if (i_VehicleType == eVehicleType.ElectricMotorcycle)
            {
                energyType = new ElectricEnergy(k_ElectricMotorcycleMaxEnergyCapacity);
                newVehicle = new Motorcycle(i_LicensePlate, energyType);
            }
            else if (i_VehicleType == eVehicleType.FuelMotorcycle)
            {
                energyType = new FuelEnergy(FuelEnergy.eFuelType.Octan96, k_FuelMotorcycleMaxEnergyCapacity);
                newVehicle = new Motorcycle(i_LicensePlate, energyType);
            }
            else if (i_VehicleType == eVehicleType.FuelTruck)
            {
                energyType = new FuelEnergy(FuelEnergy.eFuelType.Soler, k_TruckMaxEnergyCapacity);
                newVehicle = new Truck(i_LicensePlate, energyType);
            }
            else
            {
                throw new ArgumentException("Invalid vehicle type inserted!");
            }

            return(newVehicle);
        }
Пример #10
0
 protected void asssaignEnergySourceToElectric(ref VehicleEnergy io_Energy, float i_CurrentAmount, float i_MaxAmount, EnergyType i_Electric)
 {
     ElectricEnergy.ValidateElectriclType(i_Electric);
     io_Energy           = new ElectricEnergy(i_CurrentAmount, i_MaxAmount);
     PercentOfEnergyLeft = percentOfEnergyLeftCalculation(i_CurrentAmount, i_MaxAmount);
 }
Пример #11
0
 internal ElectricMotorcycle(string i_LicenseNumber)
     : base(i_LicenseNumber, k_MaxWheelAirPressure, k_NumberOfWheels)
 {
     EnergySystem = new ElectricEnergy(k_MaxBatteryTime);
 }