Exemplo n.º 1
0
        public void RechargeElectricity(string i_LicensePlate, float i_Amount)
        {
            Vehicle theVehicle = getVehicleInGarage(i_LicensePlate);
            ElectricEnergySource electricEnergySource = theVehicle.EnergySource as ElectricEnergySource;

            if (electricEnergySource == null)
            {
                throw new ArgumentException("license plate doesn't belong to electric vehicle");
            }

            theVehicle.FillEnergy(i_Amount);
        }
Exemplo n.º 2
0
        private static EnergySource getEnergySource(eVehicleType i_VehicleType, eEnergySourceType i_EnergySourceType,
                                                    float i_CurrentEnergyAmount)
        {
            EnergySource energySource;

            switch (i_EnergySourceType)
            {
            case eEnergySourceType.Fuel:
                energySource = new FuelEnergySource(i_CurrentEnergyAmount,
                                                    getFuelEnergyFillingInfoByVehicleType(i_VehicleType));
                break;

            case eEnergySourceType.Electricity:
                energySource = new ElectricEnergySource(i_CurrentEnergyAmount,
                                                        getElectricityEnergyFillingInfoByVehicleType(i_VehicleType));
                break;

            default:
                throw new ArgumentOutOfRangeException("i_EnergySourceType");
            }
            return(energySource);
        }