Пример #1
0
        internal bool ValidInputFuelKind(string i_InputString, ref eFuelKinds io_FuelKind)
        {
            bool isValid = false;

            try
            {
                if (i_InputString == "Octan95" || i_InputString == "1")
                {
                    io_FuelKind = eFuelKinds.Octan95;
                    isValid     = true;
                }
                else if (i_InputString == "Octan96" || i_InputString == "2")
                {
                    io_FuelKind = eFuelKinds.Octan96;
                    isValid     = true;
                }
                else if (i_InputString == "Octan98" || i_InputString == "3")
                {
                    io_FuelKind = eFuelKinds.Octan98;
                    isValid     = true;
                }
                else if (i_InputString == "Soler" || i_InputString == "4")
                {
                    io_FuelKind = eFuelKinds.Soler;
                    isValid     = true;
                }
                else
                {
                    throw new ArgumentException();
                }
            }
            catch (ArgumentException)
            {
                Console.WriteLine("{0} is Not an Option. Please Try Again: [Octan95(1) /Octan96(2) /Octan 98(3) /Solar(4)]", i_InputString);
            }

            return(isValid);
        }
Пример #2
0
 public bool RefualVehicle(string i_PlateNumber, eFuelKinds fuelKind, float i_AmountToFuel)
 {
     return(m_DictionaryVehicles[i_PlateNumber].PossiableToFill(i_AmountToFuel));
 }
Пример #3
0
 public Fuel(eFuelKinds i_KindOfFuel, float i_MaxCapacityFuel, float i_CurrentCapacityFuel) : base(i_MaxCapacityFuel, i_CurrentCapacityFuel)
 {
     m_KindOfFuel = i_KindOfFuel;
 }
Пример #4
0
        private void Refuel()//function 5
        {
            string     plateNumber;
            string     inputString;
            eFuelKinds fuelKind      = 0;
            float      amountToFuel  = 0;
            bool       isDetailMatch = false;

            try
            {
                while (!isDetailMatch)
                {
                    plateNumber = GetExistPlateNumber();

                    if (GM.IsVehicleRunOnFuel(plateNumber))
                    {
                        System.Console.WriteLine("Please Choose Fuel Type [Octan95(1) /Octan96(2) /Octan 98(3) /Solar(4)]");
                        inputString = System.Console.ReadLine();

                        while (!IV.ValidInputFuelKind(inputString, ref fuelKind))
                        {
                            inputString = System.Console.ReadLine();
                        }

                        if (GM.GetFuelKind(plateNumber) == fuelKind)
                        {
                            System.Console.WriteLine("Please Choose Amount To Fuel: ");
                            inputString = System.Console.ReadLine();

                            while (!IV.ValidInputFloatNonNegative(inputString, ref amountToFuel))
                            {
                                inputString = System.Console.ReadLine();
                            }

                            if (!GM.RefualVehicle(plateNumber, fuelKind, amountToFuel))
                            {
                                throw new ValueOutOfRangeException("Refuel");
                            }

                            isDetailMatch = true;
                            System.Console.WriteLine("Fuel Succsesfully!");
                        }
                        else
                        {
                            throw new ArgumentException("Invalid Operation! You Try To Refuel With The Wrong Fuel Type.");
                        }
                    }
                    else
                    {
                        throw new ArgumentException("Invalid Operation! You Try To Refuel an Electronic Vehicle.");
                    }
                }
            }
            catch (ValueOutOfRangeException voore)
            {
                System.Console.WriteLine("{0}", voore.Message);
            }
            catch (ArgumentException ae)
            {
                System.Console.WriteLine("{0}", ae.Message);
            }
        }