Exemplo n.º 1
0
        public void AddFuelToVehicle(string i_PlateNumber, float i_FuelAmount, FuelVehicle.eFuelType i_FuelType)
        {
            FuelVehicle fuelVehicle = null;

            foreach (KeyValuePair <Vehicle, Owner> vehicle in m_VehiclesInGarage)
            {
                if (vehicle.Key.LicensePlateNumber == i_PlateNumber)
                {
                    fuelVehicle = vehicle.Key as FuelVehicle;

                    if (fuelVehicle == null)
                    {
                        throw new ArgumentException("This vehicle does not match this type of operation");
                    }
                    else
                    {
                        fuelVehicle.AddFuel(i_FuelAmount, i_FuelType);
                        break;
                    }
                }
            }

            if (fuelVehicle == null)
            {
                throw new ArgumentException(string.Format("Vehicle with this license plates does not exists in the Garage"));
            }
        }