Esempio n. 1
0
        public void AddElectricity(string i_LicenseNumber, float i_AmountOfPowerToAdd)
        {
            Electricity toRefill = r_VehiclesToFix[i_LicenseNumber].VehicleOfOwner.PowerSource as Electricity;

            toRefill.AddPower(i_AmountOfPowerToAdd);
            r_VehiclesToFix[i_LicenseNumber].VehicleOfOwner.UpdatePercent();
        }
Esempio n. 2
0
        public void  CanCarBeCharged(string i_LicenseNumber)
        {
            Electricity powerOfCar = r_VehiclesToFix[i_LicenseNumber].VehicleOfOwner.PowerSource as Electricity;

            if (powerOfCar == null)
            {
                throw new ArgumentException("Invalid type source the power source doesn't match the car");
            }
        }
Esempio n. 3
0
 public void ChargeVehicleAtGarage(string i_LicenseNumber, float i_MinutesToCharge)
 {
     if (IsVehicleinGarage(i_LicenseNumber))
     {
         Electricity electToCompare = m_Vehicles[i_LicenseNumber].Vehicle.EnergySource as Electricity;
         if (electToCompare != null)
         {
             electToCompare.Fill(i_MinutesToCharge / 60f);
         }
         else
         {
             throw new ArgumentException("This vehicle is NOT an electricity vehicle.");
         }
     }
     else
     {
         throw new ArgumentException("Couldn't find this license number.");
     }
 }
Esempio n. 4
0
        public static PowerUsage CreatePowerSource(
            eVehicleType i_VehicleType,
            ePowerType i_EnergyType,
            float i_AmountOfPowerSource)
        {
            PowerUsage powerSource = null;

            switch (i_VehicleType)
            {
            case eVehicleType.Car:
                if (i_EnergyType == ePowerType.Gas)
                {
                    powerSource = new Gas(Gas.eGasType.Octan96, i_AmountOfPowerSource, 50f);
                }
                else
                {
                    powerSource = new Electricity(1.6f, i_AmountOfPowerSource);
                }

                break;

            case eVehicleType.Motorcycle:
                if (i_EnergyType == ePowerType.Gas)
                {
                    powerSource = new Gas(Gas.eGasType.Octan95, i_AmountOfPowerSource, 5.5f);
                }
                else
                {
                    powerSource = new Electricity(4.8f, i_AmountOfPowerSource);
                }

                break;

            case eVehicleType.Truck:
                powerSource = new Gas(Gas.eGasType.Soler, i_AmountOfPowerSource, 105f);
                break;
            }

            return(powerSource);
        }