コード例 #1
0
        private static void addNewVehicleToGarage(GarageLogic.Garage i_Garage)
        {
            string[] specificPropertiesToGet = null;
            string[] specificPropertiesToSet = null;
            string   licenseNumber           = getUserInputOfVehicleLicenceNumberIfItIsNotExistiInGarage(i_Garage);

            if (!s_InterruptCurrTask)
            {
                UserInputOutput.WriteLine(GarageLogic.VehicleFactory.GetListOfAvailableVehiclesToBuild());
                GarageLogic.Vehicle newVehicle = buildVehilce(UserInputOutput.ReadLine());
                if (!s_InterruptCurrTask)
                {
                    setStandardDetailsOfNewVehicle(newVehicle, licenseNumber);
                    UserInputOutput.WriteLine(GarageLogic.PropulsionSystemFactory.GetListOfAvailableSystems());
                    newVehicle.SetPropulsionSystem(newVehicle.GetType().Name, UserInputOutput.ReadLine());
                    specificPropertiesToGet = newVehicle.GetSpecificPropertiesAsStrings();
                    specificPropertiesToSet = new string[specificPropertiesToGet.Length];
                    UserInputOutput.ClearScreen();
                    for (int i = 0; i < specificPropertiesToGet.Length; i++)
                    {
                        UserInputOutput.WriteLine(specificPropertiesToGet[i]);
                        specificPropertiesToSet[i] = UserInputOutput.ReadLine();
                    }

                    newVehicle.SetSpecificProperties(specificPropertiesToSet);
                    string[] ownerDetailsToSet = getOwnerDetailsOfVehicleFromUser();
                    i_Garage.SetOwnerDetailsOfVehicle(licenseNumber, ownerDetailsToSet);
                    i_Garage.AddVehicle(newVehicle);
                }
            }
        }
コード例 #2
0
        private static string getUserInputOfVehicleLicenceNumberIfItIsNotExistiInGarage(GarageLogic.Garage i_Garage)
        {
            int dummyValue;

            UserInputOutput.ClearScreen();
            UserInputOutput.WriteLine(@"Type the 'licence number' of the vehicle");
            string licenseNumberInput = UserInputOutput.ReadLine();

            while (!int.TryParse(licenseNumberInput, out dummyValue))
            {
                UserInputOutput.ClearScreen();
                UserInputOutput.WriteLine(@"Invalid input! Insert numeral value, please!");
                licenseNumberInput = UserInputOutput.ReadLine();
            }

            while (i_Garage.isVehicleExists(licenseNumberInput) && !s_InterruptCurrTask)
            {
                UserInputOutput.ClearScreen();
                UserInputOutput.WriteLine(@"
The vehicle with license number you typed already exist in garage.
Type license number of another vehicle  or press 'X' to interrupt the task.");
                s_InterruptCurrTask = isInterruptTheCurrTask(out licenseNumberInput);
            }

            return(licenseNumberInput);
        }
コード例 #3
0
        private static void writeHaveAGoodDayMsg()
        {
            UserInputOutput.ClearScreen();
            UserInputOutput.WriteLine(@"
 _   _    __  __  __  _____      __      ____   _____    _____   ____      ____     __   _   _  _
| |_| |  /__\(  )(  )(   __)    /__\    / ___) /  _  \  /  _  \ |  _  \   |  _  \  /__\ ( \_/ )/ \
|  _  | /(__)\\ \/ / |  >__    /(__)\  ( (___n(  (_)  )(  (_)  )| |_)  )  | |_)  )/(__)\ \   / \_/
|_| |_|(__)(__)\__/  (_____)  (__)(__)  \____/ \_____/  \_____/ |_____/   |_____/(__)(__)(__/   O
===================================================================================================");
        }
コード例 #4
0
        private static void showAllCurrentInformationOfVihecle(GarageLogic.Garage i_Garage)
        {
            string licenseNumber = getUserInputOfVehicleLicenceNumberIfItExistsInGarage(i_Garage);

            if (!s_InterruptCurrTask)
            {
                UserInputOutput.ClearScreen();
                UserInputOutput.WriteLine(i_Garage.GetAllDetailsOfVehicle(licenseNumber));
            }
        }
コード例 #5
0
        public static void WriteErrorMsg()
        {
            UserInputOutput.ClearScreen();
            UserInputOutput.WriteLine(@"
 _____  _____   _____   _____   _____    _
(   __)(  O  ) (  O  ) /  _  \ (  O  )  / \
|  >__ |     \ |     \(  (_)  )|     \  \_/
(_____)(__)\__)(__)\__)\_____/ (__)\__)  O
==========================================
");
        }
コード例 #6
0
        private static void showVehiclesStatusOptions()
        {
            UserInputOutput.ClearScreen();
            UserInputOutput.WriteLine(@"
Choose a repair status of the following options, please:
============================================
1-> Under repair
2-> Fixed
3-> Paid
4-> All statuses");
        }
コード例 #7
0
 private static void setStandardDetailsOfNewVehicle(GarageLogic.Vehicle i_Vehicle, string i_LicenseNum)
 {
     UserInputOutput.ClearScreen();
     i_Vehicle.LicenseNum = i_LicenseNum;
     UserInputOutput.WriteLine(@"Enter the model name of your vehicle, please");
     i_Vehicle.ModelName = UserInputOutput.ReadLine();
     for (int i = 0; i < i_Vehicle.WheelsNum; i++)
     {
         UserInputOutput.WriteLine(string.Format(@"Enter the manufacturer name of {0} wheel, please", i + 1));
         i_Vehicle.SetManufacturerNameOfSpecificWheel(i, UserInputOutput.ReadLine());
     }
 }
コード例 #8
0
        private static void chargeElectricVehicle(GarageLogic.Garage i_Garage)
        {
            UserInputOutput.ClearScreen();
            UserInputOutput.WriteLine(@"Type an amount of minutes to charge");
            float  minutesToCharge = float.Parse(UserInputOutput.ReadLine());
            string licenseNumber   = getUserInputOfVehicleLicenceNumberIfItExistsInGarage(i_Garage);

            if (!s_InterruptCurrTask)
            {
                i_Garage.ChargeVehicleThatBasedOnElectricSystem(licenseNumber, minutesToCharge);
            }
        }
コード例 #9
0
        private static GarageLogic.Vehicle buildVehilce(string i_TypeOfVehicle)
        {
            GarageLogic.Vehicle newVehicle = GarageLogic.VehicleFactory.BuildNewVehicle(i_TypeOfVehicle);

            while (newVehicle == null && !s_InterruptCurrTask)
            {
                UserInputOutput.ClearScreen();
                UserInputOutput.WriteLine(
                    @"This type of the vehicle, you inserted doesn't created on our vehicle factory.
Insert another type of vehicl or press 'X' to interrupt the task.");
                s_InterruptCurrTask = isInterruptTheCurrTask(out i_TypeOfVehicle);
                newVehicle          = GarageLogic.VehicleFactory.BuildNewVehicle(i_TypeOfVehicle);
            }

            return(newVehicle);
        }
コード例 #10
0
        private static string[] getOwnerDetailsOfVehicleFromUser()
        {
            const int k_AmountOfDetails = 2;

            string[] result = new string[k_AmountOfDetails];

            UserInputOutput.ClearScreen();
            UserInputOutput.WriteLine(
                @"Type vehicle's owner name first and owner phone number second 
(press enter after each input)");
            for (int i = 0; i < k_AmountOfDetails; i++)
            {
                result[i] = UserInputOutput.ReadLine();
            }

            return(result);
        }
コード例 #11
0
        private static string getUserInputOfVehicleLicenceNumberIfItExistsInGarage(GarageLogic.Garage i_Garage)
        {
            UserInputOutput.ClearScreen();
            UserInputOutput.WriteLine(@"Type the 'licence number' of the vehicle");
            string licenseNumberInput = UserInputOutput.ReadLine();

            while (!i_Garage.isVehicleExists(licenseNumberInput) && !s_InterruptCurrTask)
            {
                UserInputOutput.ClearScreen();
                UserInputOutput.WriteLine(@"
The license number of vehicle you typed is not found.
Please check your input before you type again or
press 'X' to interrupt the task.
");
                s_InterruptCurrTask = isInterruptTheCurrTask(out licenseNumberInput);
            }

            return(licenseNumberInput);
        }
コード例 #12
0
        private static void showGarageMenu()
        {
            s_InterruptCurrTask = false;
            UserInputOutput.ClearScreen();
            UserInputOutput.WriteLine(
                @"************
GARAGE MENU:
************
Choose one the following operations to do:
==========================================
1-> Add a new vehicle to the garage 
2-> Show the vehicles according their repair status 
3-> Change repair status of the vehicle
4-> Inflate the wheels to maximum pressure
5-> Refuel fuel vehicle
6-> Charge electric vehicle
7-> Show all current information about the vehicle

Press 'Q' for exit
");
        }
コード例 #13
0
        private static void refeulFuelVehicle(GarageLogic.Garage i_Garage)
        {
            UserInputOutput.ClearScreen();
            UserInputOutput.WriteLine(@"Type an amount of fuel you want to refill in liters");
            float litersOfFuelToRefuel = float.Parse(UserInputOutput.ReadLine());

            UserInputOutput.WriteLine(@"
Choose a type of fuel:
=====================
1-> Octan98
2-> Octan96
3-> Octan95
4-> Soler");
            GarageLogic.FuelType fuelType = GarageLogic.FuelType.Parse(UserInputOutput.ReadLine());
            string licenseNumber          = getUserInputOfVehicleLicenceNumberIfItExistsInGarage(i_Garage);

            if (!s_InterruptCurrTask)
            {
                i_Garage.FillFuelInVehicleThatBasedOnFuelSystem(licenseNumber, fuelType, litersOfFuelToRefuel);
            }
        }
コード例 #14
0
        private static void changeVehicleStatusAccordingThekey(GarageLogic.Garage i_Garage)
        {
            showVehiclesStatusOptions();
            GarageLogic.GarageVehicleStatus key = GarageLogic.GarageVehicleStatus.Parse(UserInputOutput.ReadLine());
            while (key.VehicleStatus == GarageLogic.eGarageVehicleStatus.AllStatuses)
            {
                UserInputOutput.ClearScreen();
                UserInputOutput.WriteLine(
                    @"
You can't change a vehicle's status to all statuses, choose only one statuse please!");
                showVehiclesStatusOptions();
                key = GarageLogic.GarageVehicleStatus.Parse(UserInputOutput.ReadLine());
            }

            string licenseNumber = getUserInputOfVehicleLicenceNumberIfItExistsInGarage(i_Garage);

            if (!s_InterruptCurrTask)
            {
                i_Garage.ChangeVehicleStatus(licenseNumber, key);
            }
        }
コード例 #15
0
        private static void showLicenseNumsOfVehiclesAccordingTheKey(GarageLogic.Garage i_Garage)
        {
            string[] licenseNumsContainer = null;

            showVehiclesStatusOptions();
            GarageLogic.GarageVehicleStatus key = GarageLogic.GarageVehicleStatus.Parse(UserInputOutput.ReadLine());
            UserInputOutput.ClearScreen();
            if (key.VehicleStatus == GarageLogic.eGarageVehicleStatus.AllStatuses)
            {
                licenseNumsContainer = i_Garage.GetLicenseNumsOfAllVehicles();
            }
            else
            {
                licenseNumsContainer = i_Garage.GetLicenseNumsOfAllVehiclesWithSpecStatus(key);
            }

            foreach (string value in licenseNumsContainer)
            {
                UserInputOutput.WriteLine(value);
            }
        }