Exemplo n.º 1
0
    private static Ex03.GarageLogic.FuelTank.eFuelType auxGetFuelType()
    {
        Ex03.GarageLogic.FuelTank.eFuelType fuelType = 0;
        string stringEnumType = getEnumStringFromEnumValues(typeof(Ex03.GarageLogic.FuelTank.eFuelType));

        fuelType = (Ex03.GarageLogic.FuelTank.eFuelType)System.Enum.Parse(typeof(Ex03.GarageLogic.FuelTank.eFuelType), stringEnumType);
        return(fuelType);
    }
Exemplo n.º 2
0
    /// <summary>
    /// This function tries to fuel a vehicle of input number and catches 3 optional exceptions:
    /// 1. <remarks>ArgumentException</remarks> in case of trying to fuel electric car
    /// 2. <remarks>ArgumentException</remarks> in case of trying to fuel car with mismatching fuel type
    /// 3. <remarks>ValueOutOfRange</remarks> Exception in case of the action of fueling will exceed the maximum fuel tank's capacity
    /// </summary>
    /// <param name="i_ExistingVehicleNumber"></param>
    /// <param name="i_GarageManager"></param>
    private static void fuelGasVehicle(string i_ExistingVehicleNumber, Ex03.GarageLogic.GarageManager i_GarageManager)
    {
        Ex03.GarageLogic.FuelTank.eFuelType fuelType = auxGetFuelType();
        System.Console.WriteLine("Please enter amount of fuel (in Liters) to fuel");
        float amountOfLitersToFuel = getPositiveValidFloat();

        System.Console.WriteLine();
        try
        {
            i_GarageManager.FuelGasVehicle(i_ExistingVehicleNumber, fuelType, amountOfLitersToFuel);
            System.Console.WriteLine("Succes: vehicle was fueled succesfully with {0} liters..." + Environment.NewLine, amountOfLitersToFuel);
        }
        catch (Exception ex)
        {
            System.Console.WriteLine(ex.Message);
        }
    }