public bool ChargeElectricVehicle(string i_LicensePlate, float i_AmountOfMinutes) { bool carFound = false; foreach (GarageVehicle garageVehicle in m_Vehicles) { if (garageVehicle.Vehicle.LicensePlate.Equals(i_LicensePlate)) { carFound = true; Battery battery = garageVehicle.Vehicle.PowerSource as Battery; if (battery == null) { throw new ArgumentException("This vehicle isn't electric"); } else { battery.Charge(i_AmountOfMinutes); } break; } } return(carFound); }
public void ChargeVehicle(string i_LicenseNumber, float i_AmountOfMinutesToAdd) { VehicleInfo vehicleInfo = r_Vehicles[i_LicenseNumber]; if (vehicleInfo.Vehicle != null) { if (r_Vehicles[i_LicenseNumber].Vehicle != null) { Battery battery = r_Vehicles[i_LicenseNumber].Vehicle.EnergySource as Battery; battery.Charge(i_AmountOfMinutesToAdd); } else { throw new VehicleNotExistException(i_LicenseNumber); } } else { throw new VehicleNotExistException(i_LicenseNumber); } }