Beispiel #1
0
 public void RechargeVehicl(float i_MinutesToCharge, string i_LicenseNumber)
 {
     if (r_AllVehiclesInfo != null && r_AllVehiclesInfo.ContainsKey(i_LicenseNumber))
     {
         ElectricEngine ElectricEngine = r_AllVehiclesInfo[i_LicenseNumber].OwenersVehicle.Engine as ElectricEngine;
         if (ElectricEngine != null)
         {
             if (eEngineType.Electric == ElectricEngine.CurrentEngineType)
             {
                 r_AllVehiclesInfo[i_LicenseNumber].OwenersVehicle.Engine.AddEnergy(eEngineType.Electric, i_MinutesToCharge / 60);
             }
         }
         else
         {
             throw new ArgumentException("This vehicle does not have an electric engine");
         }
     }
     else
     {
         throw new ArgumentException("This vehicle is not in our garage");
     }
 }
Beispiel #2
0
        public object CreateGarageObject(object[] i_Parameters, Type i_Type, Type i_VehicleType)
        {
            object obj;

            Enums.eVehicleType vehicleType = (Enums.eVehicleType)Enum.Parse(typeof(Enums.eVehicleType), i_VehicleType.Name);

            if (i_Type == typeof(Wheel))
            {
                float           maxEnergy = (float)VehiclesDefualtConfigurations.sr_DefaultDictionary[vehicleType]["Maximum Air Pressure"];
                ConstructorInfo ci        = i_Type.GetConstructors()[0];
                i_Parameters[i_Parameters.Length - 1] = maxEnergy;
                obj = new Wheel((string)i_Parameters[0], (float)i_Parameters[1], (float)i_Parameters[2]);
            }
            if (i_Type == typeof(ElectricEngine))
            {
                float           maxEnergy = (float)VehiclesDefualtConfigurations.sr_DefaultDictionary[vehicleType]["Maximum Energy"];
                ConstructorInfo ci        = i_Type.GetConstructors()[0];
                i_Parameters[i_Parameters.Length - 1] = maxEnergy;
                obj = new ElectricEngine((float)i_Parameters[0], (float)i_Parameters[1]);
            }
            else if (i_Type == typeof(FuelEngine))
            {
                Enums.eFuelTypes fuelType  = (Enums.eFuelTypes)VehiclesDefualtConfigurations.sr_DefaultDictionary[vehicleType]["Fuel Type"];
                float            maxEnergy = (float)VehiclesDefualtConfigurations.sr_DefaultDictionary[vehicleType]["Maximum Energy"];
                ConstructorInfo  ci        = i_Type.GetConstructors()[0];
                i_Parameters[i_Parameters.Length - 2] = maxEnergy;
                i_Parameters[i_Parameters.Length - 1] = fuelType;
                obj = new FuelEngine((float)i_Parameters[0], (float)i_Parameters[1], (Enums.eFuelTypes)i_Parameters[2]);
            }
            else
            {
                ConstructorInfo ci = i_Type.GetConstructors()[0];
                obj = ci.Invoke(i_Parameters);
            }

            return(obj);
        }
Beispiel #3
0
 internal ElectricMotorcycle(string i_LicenseNumber, string i_ModelType, string i_ManufacturerName)
     : base(i_LicenseNumber, i_ModelType, i_ManufacturerName)
 {
     m_TypeEngine = new ElectricEngine(m_ElectricType, k_MaxAmountOfBattery);
 }