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); }
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); } } }
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); } }
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()); } }
private static void exitIfUserDidNotChooseAnyOption() { if (!s_Exit && !s_InterruptCurrTask) { UserInputOutput.WriteLine(@" Press any key to go back to 'Garage Menu' or press Q to exit the program"); string input = UserInputOutput.ReadLine(); // $G$ CSS-999 (-2) You should have used constant if (input == "Q" || input == "q") { s_Exit = true; } } }
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); }
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); }
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); } }
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); } }
private static bool isInterruptTheCurrTask(out string io_Input) { io_Input = UserInputOutput.ReadLine(); return(io_Input == k_Interruption || io_Input == "x"); }
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); } }