public IOhandler()
 {
     m_Validator = new InputValidator();
     m_UI        = new UI();
     m_Garage    = new GarageLogic.Garage();
 }
Esempio n. 2
0
        private void ShowRegisteredVehicles()
        {
            string filter = UI.GetFilterInput();

            UI.ShowAllRegisteredVehicles(m_Garage.GetAllLicenseNumbers(filter));
        }
 public static void Main()
 {
     UI.Run();
 }
Esempio n. 4
0
        public static void StartAction(GarageLogic.GarageLogic i_Garage)
        {
            string stringAction = getAction();
            byte   action       = isValidAction(stringAction);

            while (action == 0)
            {
                stringAction = getAction();
                action       = isValidAction(stringAction);
            }

            if (action == 1)
            {
                EnterNewVehicle(i_Garage);
            }
            else if (action == 2)
            {
                string withOrWithoutFilter     = getWithOrWithoutFilter();
                byte   byteWithOrWithoutFilter = isValidFilter(withOrWithoutFilter);

                while (byteWithOrWithoutFilter == 0)
                {
                    withOrWithoutFilter     = getWithOrWithoutFilter();
                    byteWithOrWithoutFilter = isValidFilter(withOrWithoutFilter);
                }

                if (byteWithOrWithoutFilter == 1)
                {
                    string[] states = i_Garage.GetVehicleStates();
                    Console.WriteLine(states[0]);
                    string state      = Console.ReadLine();
                    object validState = ParseAnswer(states[1], state);

                    while (validState == null)
                    {
                        Console.WriteLine("Invalid type - {0} should be {1}", state, states[1]);
                        Console.WriteLine(states[0]);
                        state      = Console.ReadLine();
                        validState = UI.ParseAnswer(states[1], state);
                    }

                    Console.WriteLine(i_Garage.DisplayVehiclesLicenses(state));
                }
                else if (byteWithOrWithoutFilter == 2)
                {
                    Console.WriteLine(i_Garage.DisplayVehiclesLicenses());
                }
            }
            else
            {
                string licenseNumber      = getString("license number");
                bool   licenseNumberValid = isValidNumber(licenseNumber, "license number");

                while (!licenseNumberValid)
                {
                    licenseNumber      = getString("license number");
                    licenseNumberValid = isValidNumber(licenseNumber, "license number");
                }

                if (action == 3)
                {
                    string[] states = i_Garage.GetVehicleStates();
                    Console.WriteLine(states[0]);
                    string state      = Console.ReadLine();
                    object validState = ParseAnswer(states[1], state);

                    while (validState == null)
                    {
                        Console.WriteLine("Invalid type - {0} should be {1}", state, states[1]);
                        Console.WriteLine(states[0]);
                        state      = Console.ReadLine();
                        validState = UI.ParseAnswer(states[1], state);
                    }

                    Console.WriteLine(i_Garage.UpdateVehicleState(licenseNumber, state));
                }
                else if (action == 4)
                {
                    Console.WriteLine(i_Garage.InflateVehicleWheels(licenseNumber));
                }
                else if (action == 5)
                {
                    string[] fuelTypes = i_Garage.GetFuelTypes();
                    Console.WriteLine(fuelTypes[0]);
                    string fuelType      = Console.ReadLine();
                    object validFuelType = ParseAnswer(fuelTypes[1], fuelType);

                    while (validFuelType == null)
                    {
                        Console.WriteLine("Invalid type - {0} should be {1}", fuelType, fuelTypes[1]);
                        Console.WriteLine(fuelTypes[0]);
                        fuelType      = Console.ReadLine();
                        validFuelType = ParseAnswer(fuelTypes[1], fuelType);
                    }

                    string fuelAmount      = getString("fuel amount");
                    object fuelAmountValid = ParseAnswer("float", fuelAmount);

                    while (fuelAmountValid == null)
                    {
                        Console.WriteLine("Invalid type - {0} should be {1}", fuelAmount, "float");
                        fuelAmount      = getString("fuel amount");
                        fuelAmountValid = ParseAnswer("float", fuelAmount);
                    }

                    try
                    {
                        Console.WriteLine(i_Garage.FuelNormalVehicle(licenseNumber, fuelType, (float)fuelAmountValid));
                    }
                    catch (Exception e)
                    {
                        e.ToString();
                    }
                }
                else if (action == 6)
                {
                    string minutesToCharge      = getString("minutes to charge");
                    object minutesToChargeValid = ParseAnswer("float", minutesToCharge);

                    while (minutesToChargeValid == null)
                    {
                        Console.WriteLine("Invalid type - {0} should be {1}", minutesToCharge, "float");
                        minutesToCharge      = getString("minutes to charge");
                        minutesToChargeValid = ParseAnswer("float", minutesToCharge);
                    }

                    try
                    {
                        Console.WriteLine(i_Garage.ChargeElectricVehicle(licenseNumber, (float)minutesToChargeValid));
                    }
                    catch (Exception e)
                    {
                        e.ToString();
                    }
                }
                else if (action == 7)
                {
                    Console.WriteLine(i_Garage.DisplayVehicleData(licenseNumber));
                }
            }
        }
Esempio n. 5
0
        // $G$ CSS-999 (-3) The method must have an access modifier.
        static void Main(string[] args)
        {
            UI consoleUI = new UI();

            consoleUI.startEngine();
        }