예제 #1
0
        internal static void ShowFuelGasVehicleMenu(GarageLogic i_MyGarage)
        {
            Console.Clear();
            Console.WriteLine("Please enter vehicle license plate");

            string licensePlateNumber = Console.ReadLine();

            if (i_MyGarage.CheckIfVehicleIsExists(licensePlateNumber))
            {
                Vehicle userCar = i_MyGarage.GetVehicleByLicensePlate(licensePlateNumber);
                if (userCar.Engine is GasEngine == false)
                {
                    Console.Clear();
                    Console.WriteLine("This vehicle is not Gasoline vehicle ");
                }
                else
                {
                    GasEngine userEngine      = (GasEngine)userCar.Engine;
                    float     validFuelAmount = getValidFuelAmountOfValidFuelType(userEngine);
                    userEngine.FillUpGas(validFuelAmount, userEngine.GasType);
                    Console.WriteLine("Fueling...");
                    Thread.Sleep(2000);
                    Console.Clear();
                }
            }
            else
            {
                Console.Clear();
                Console.WriteLine("This vehicle is not found in our garage ");
            }
        }
예제 #2
0
        internal static void ShowInsertVehicleToGarageMenu(GarageLogic i_MyGarage)
        {
            Console.Clear();
            Console.WriteLine("Please enter vehicle license plate");
            string licensePlateNumber = Console.ReadLine();

            if (i_MyGarage.CheckIfVehicleIsExists(licensePlateNumber))
            {
                Console.Clear();
                Console.WriteLine("The vehicle is already exists");
                i_MyGarage.SetStatusInVehicle(licensePlateNumber, Record.eVehicleStatus.inRepair);
            }
            else
            {
                Console.WriteLine("Please insert your name:");
                string ownerName = Console.ReadLine();
                Console.WriteLine("Please insert your phone number:");
                string ownerPhoneNumber = Console.ReadLine();
                Console.Clear();
                insertNewVehicleToGarage(licensePlateNumber, i_MyGarage, ownerName, ownerPhoneNumber);
                Console.WriteLine("The vehicle was successfully added to the garage.");
            }

            Thread.Sleep(3000);
        }
예제 #3
0
        internal static void ShowChargeElectricVehicleMenu(GarageLogic i_MyGarage)
        {
            Console.Clear();
            Console.WriteLine("Please enter vehicle license plate");

            string licensePlateNumber = Console.ReadLine();

            if (i_MyGarage.CheckIfVehicleIsExists(licensePlateNumber))
            {
                Vehicle userCar = i_MyGarage.GetVehicleByLicensePlate(licensePlateNumber);
                if (userCar.Engine is ElectricEngine == false)
                {
                    Console.Clear();
                    Console.WriteLine("This vehicle is not and electric vehicle ");
                }
                else
                {
                    ElectricEngine userEngine           = (ElectricEngine)userCar.Engine;
                    float          validMinutesToCharge = getValidMinutesToCharge(userEngine);
                    userEngine.ChargeBattery(validMinutesToCharge);
                    Console.WriteLine("Charging...");
                    Thread.Sleep(2000);
                    Console.Clear();
                }
            }

            else
            {
                Console.Clear();
                Console.WriteLine("This vehicle is not found in our garage ");
            }

            Thread.Sleep(2000);
        }
예제 #4
0
        private static void getUserInputStatusAndChangeIt(GarageLogic i_MyGarage, string i_OwnerPlateNumber)
        {
            int  userSelection  = 1;
            bool validSelection = false;

            while (validSelection == false)
            {
                Console.WriteLine(@"To which status would you like to change?
1. In repair
2. Is fixed,
3. Is paid up");

                string stringUserSelection = Console.ReadLine();
                validSelection = int.TryParse(stringUserSelection, out userSelection);
                if (validSelection == true)
                {
                    if (userSelection < 1 || userSelection > 3)
                    {
                        validSelection = false;
                    }
                }

                if (validSelection == false)
                {
                    Console.Clear();
                    Console.WriteLine("Invalid selection please try again! ");
                }
            }

            setVehicleStatusInTheGarage(i_MyGarage, i_OwnerPlateNumber, userSelection);
        }
예제 #5
0
        private static void insertNewVehicleToGarage(string i_LicensePlate, GarageLogic i_MyGarage, string i_OwnerName, string i_OwnerPhoneNumber)
        {
            string vehicleTypeToInsert = getFromUserTypeOfVehicle();

            try
            {
                Vehicle       vehicleToAdd       = VehicleFactory.CreateVehicle(vehicleTypeToInsert, i_LicensePlate);
                List <string> vehicleSpecsNeeded = vehicleToAdd.GetsSpecs();
                getInformationFromUserAboutTheVehicle(vehicleSpecsNeeded, vehicleToAdd);
                Record recordToAdd = new Record(i_OwnerName, i_OwnerPhoneNumber, vehicleToAdd);
                i_MyGarage.AddVehicleToGarageRecords(recordToAdd);
            }
            catch (ArgumentException exception)
            {
                Console.Clear();
                Console.WriteLine(exception.Message);
                insertNewVehicleToGarage(i_LicensePlate, i_MyGarage, i_OwnerName, i_OwnerPhoneNumber);
            }
            catch (ValueOutOfRangeException exception)
            {
                Console.Clear();
                Console.WriteLine(exception.Message);
                insertNewVehicleToGarage(i_LicensePlate, i_MyGarage, i_OwnerName, i_OwnerPhoneNumber);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
            }

            Console.Clear();
        }
        public static void PlayMainMenuAndOpenGarage()
        {
            GarageLogic myGarage      = new GarageLogic();
            int         userSelection = 0;

            while (userSelection != (int)eMainGarageMenu.Exit)
            {
                userSelection = showMainGarageMenuAndGetUserInput();
                showSubMenuUsingUserSelection(userSelection, myGarage);
                Console.Clear();
            }
        }
예제 #7
0
        public static void ShowChangeVehiclesStatusMenu(GarageLogic i_MyGarage)
        {
            Console.WriteLine("Please insert the plate number of the vehicle");
            string ownerPlateNumber = Console.ReadLine();

            if (i_MyGarage.CheckIfVehicleIsExists(ownerPlateNumber) == false)
            {
                Console.WriteLine("The vehicle isn't in the garage.");
            }
            else
            {
                getUserInputStatusAndChangeIt(i_MyGarage, ownerPlateNumber);
            }
        }
        private static void showSubMenuUsingUserSelection(int i_UserSelection, GarageLogic i_MyGarage)
        {
            switch (i_UserSelection)
            {
            case (int)eMainGarageMenu.InsertVehicleToGarage:
            {
                InsertVehicleToGarageMenu.ShowInsertVehicleToGarageMenu(i_MyGarage);
                break;
            }

            case (int)eMainGarageMenu.ShowVehicles:
            {
                GetListOfVehiclePlateNumberMenu.ShowGetListOfVehiclePlateNumberMenu(i_MyGarage);
                break;
            }

            case (int)eMainGarageMenu.ChangeVehiclesStatus:
            {
                ChangeVehicleStatusInGarageMenu.ShowChangeVehiclesStatusMenu(i_MyGarage);
                break;
            }

            case (int)eMainGarageMenu.InflateVehicleTires:
            {
                InflateVehicleTiresMenu.ShowInflateVehicleTiresMenu(i_MyGarage);
                break;
            }

            case (int)eMainGarageMenu.FuelGasVehicle:
            {
                FuelGasCarMenu.ShowFuelGasVehicleMenu(i_MyGarage);
                break;
            }

            case (int)eMainGarageMenu.ChargeElectricVehicle:
            {
                ChargeElectricCarMenu.ShowChargeElectricVehicleMenu(i_MyGarage);
                break;
            }

            case (int)eMainGarageMenu.ShowVehicleDetails:
            {
                ShowVehicleDetailsMenu.ShowShowVehicleDetailsMenu(i_MyGarage);
                break;
            }
            }
        }
예제 #9
0
        public static void ShowGetListOfVehiclePlateNumberMenu(GarageLogic i_MyGarage)
        {
            Console.Clear();
            int    userSelection = getUserSelection();
            string message       = null;

            switch (userSelection)
            {
            case (int)eGetVehiclesListMenu.AllVehicles:
            {
                presentVehiclesPlateNumberList(i_MyGarage.Records);
                break;
            }

            case (int)eGetVehiclesListMenu.FixedVehicles:
            {
                List <Record> fixedVehicleList =
                    i_MyGarage.GetListAccordingToStatus(Record.eVehicleStatus.isFixed, ref message);
                Console.WriteLine(message);
                presentVehiclesPlateNumberList(fixedVehicleList);
                break;
            }

            case (int)eGetVehiclesListMenu.PaidForVehicles:
            {
                List <Record> paidVehicleList =
                    i_MyGarage.GetListAccordingToStatus(Record.eVehicleStatus.isPaidUp, ref message);
                Console.WriteLine(message);
                presentVehiclesPlateNumberList(paidVehicleList);
                break;
            }

            case (int)eGetVehiclesListMenu.IsBeingRepairedVehicles:
            {
                List <Record> repairedVehicleList =
                    i_MyGarage.GetListAccordingToStatus(Record.eVehicleStatus.inRepair, ref message);
                Console.WriteLine(message);
                presentVehiclesPlateNumberList(repairedVehicleList);
                break;
            }
            }
        }
예제 #10
0
        internal static void ShowInflateVehicleTiresMenu(GarageLogic i_MyGarage)
        {
            Console.Clear();
            Console.WriteLine("Please enter vehicle license plate");
            string licensePlateNumber = Console.ReadLine();

            if (i_MyGarage.CheckIfVehicleIsExists(licensePlateNumber))
            {
                Console.Clear();
                Console.Write("How much air would you like to add ?");
                Vehicle userCar          = i_MyGarage.GetVehicleByLicensePlate(licensePlateNumber);
                float   validAirPressure = getValidAirPressure(userCar);
                userCar.InflateAllTires(validAirPressure);
            }
            else
            {
                Thread.Sleep(3000);
                Console.WriteLine("License plate doesn't exist in our system");
            }
        }
        internal static void ShowShowVehicleDetailsMenu(GarageLogic i_MyGarage)
        {
            Console.Clear();
            Console.WriteLine("Please enter vehicle license plate");

            string licensePlateNumber = Console.ReadLine();

            if (i_MyGarage.CheckIfVehicleIsExists(licensePlateNumber))
            {
                Record vehicleRecord = i_MyGarage.GetRecordByLicensePlate(licensePlateNumber);
                Console.WriteLine(vehicleRecord.ToString());
            }
            else
            {
                Console.Clear();
                Console.WriteLine("This vehicle is not found in our garage ");
            }

            Console.Write("Press ENTER to continue");
            Console.ReadLine();
        }
예제 #12
0
        private static void setVehicleStatusInTheGarage(GarageLogic i_MyGarage, string i_OwnerPlateNumber,
                                                        int i_StatusToChange)
        {
            switch (i_StatusToChange)
            {
            case (int)eSetStatusMenu.inRepair:
            {
                i_MyGarage.SetStatusInVehicle(i_OwnerPlateNumber, Record.eVehicleStatus.inRepair);
                break;
            }

            case (int)eSetStatusMenu.isFixed:
            {
                i_MyGarage.SetStatusInVehicle(i_OwnerPlateNumber, Record.eVehicleStatus.isFixed);
                break;
            }

            case (int)eSetStatusMenu.isPaidUp:
            {
                i_MyGarage.SetStatusInVehicle(i_OwnerPlateNumber, Record.eVehicleStatus.isPaidUp);
                break;
            }
            }
        }
예제 #13
0
파일: UI.cs 프로젝트: shameshame/.Net
 public UI()
 {
     m_Logic = new GarageLogic();
 }