private static void GetLicenseIDsParser() { List <string> licenseIDs; Messages.askForBool("you want to filter vehicle license IDs by status"); if (r_UIGarageTypesParser.parseBool(ReciveInput())) { Messages.askForVehcleStatus(); int i_input = ReciveInputAsInt(); eGarageVehicleStatus statusOfVehicle = r_UIGarageTypesParser.parseGarageVehicleStatus(i_input); licenseIDs = Garage.GetLicenseIDsWithFilter(statusOfVehicle); } else { licenseIDs = Garage.GetLicenseIDs(); } Console.Clear(); Messages.printShortMessage(@"Garage Vehicles are:"); foreach (string licenseID in licenseIDs) { Console.WriteLine(licenseID); } }
private List <string> userDisplayLicenseNumbersChoice(Garage i_Garage) { List <string> licenseNumbers; string userChose = getNumberValidInput(); if (userChose.Equals("1")) { licenseNumbers = i_Garage.LicenseNumbersOfVehicles(); } else if (userChose.Equals("2")) { Console.WriteLine("Enter the status of vehicles(Repairing, Repaired, Paid)"); string userStatusChoise = Console.ReadLine(); Garage.eStatusVehicle statusOfVehicle = wantedNewStatus(userStatusChoise); licenseNumbers = i_Garage.LicenseNumbersOfVehiclesByTheirStatus(statusOfVehicle); } else { throw new ArgumentException(); } return(licenseNumbers); }
private static void printCarList(Garage io_Garage) { Console.WriteLine(string.Format (@"If you want to filter results please press'y' and then press enter in case you do not want to filter the result press any other key and then press enter")); String inputFromUser = Console.ReadLine(); bool toFilter = (inputFromUser == "y"); List <string> listOfVehicleToString; if (toFilter) { Console.WriteLine(string.Format( "Please enter the category that you are looking for")); Garage.GarageVehicle.eVehicleStatus theStatusTheUserChose = getValidStatusCar(); listOfVehicleToString = io_Garage.GetListOfLicensePlateNumbersOfVehiclesInGarageWithFilter (theStatusTheUserChose); } else { listOfVehicleToString = io_Garage.GetListOfLicensePlateNumbersOfVehiclesInGarage(); } if (listOfVehicleToString.Count == 0) { Console.WriteLine("No Vehicles in garage!"); } else { Console.WriteLine("This are the list of cars according to your request:"); foreach (string vehicle in listOfVehicleToString) { Console.WriteLine(vehicle); } } }
public static void FuelVehicle(Garage i_Garage) { string o_LicenseNumber = null; Fuel.eFuelType o_FuelType; float o_FuelToAdd; bool validInput = false; GetVehicleLicenseNumberFromUser(out o_LicenseNumber); GetFuelTypeFromUser(out o_FuelType); GetFuelToAddFromUser(out o_FuelToAdd); while (validInput == false) { try { validInput = i_Garage.FuelVehicle(o_LicenseNumber, o_FuelToAdd, o_FuelType); } catch (KeyNotFoundException) { Console.WriteLine("License Number does not exist in the garage"); } catch (ArgumentNullException) // electric vehicle { Console.WriteLine("The vehicle has no fuel tank"); } catch (ValueOutOfRangeException ex) { Console.WriteLine("Cannot fuel vehilce over the maximum fuel capacity of" + ex.MaxValue); } catch (WrongFuelException ex) { Console.WriteLine("Cannot fuel vehicle with {0} fuel type instead of {1}", ex.WrongFuel, ex.Fuel); } } }
private static void changeVehicleStatus(Garage i_Garage) { Console.WriteLine("Please enter your license number:"); string licenseNum = checkIfnotEmpty(Console.ReadLine()); Console.WriteLine(@"Please choose the new status from the list: 1. In repair. 2. Fixed. 3. Paid."); int userSelection = checkIfValidOption(Console.ReadLine(), 3, 0); try { switch (userSelection) { case 1: i_Garage.ChangeVehicleStatus(licenseNum, "InRepair"); break; case 2: i_Garage.ChangeVehicleStatus(licenseNum, "Fixed"); break; case 3: i_Garage.ChangeVehicleStatus(licenseNum, "Paid"); break; } Console.WriteLine("Status was successfully changed"); } catch (ArgumentException ex) { Console.WriteLine(ex.Message); } }
private static void insertNewVeichleToGarageOption(Garage io_ThisGarage) { string vehicleLicenseNumber = GarageInterface.GetVeichleLicenseNumberFromUser(); if (io_ThisGarage.IsVehicleInThisGarage(vehicleLicenseNumber)) { io_ThisGarage.ChangeInGargeStateOfVehicle(vehicleLicenseNumber, k_InRepairState); GarageInterface.SendVeichleAlreadyInGarageAsOutput(vehicleLicenseNumber); GarageInterface.SendSucsses(); } else { List<string> listOfPossibleVehicleTypes = io_ThisGarage.GetListOfPossibleVehicles(); string newVehicleType = GarageInterface.GetVehicleTypeFromUser(listOfPossibleVehicleTypes); List<string> nameOfRequiredFieldsByVehicle = io_ThisGarage.GetParametersDict(newVehicleType); Dictionary<string, string> parametersForFactory = GarageInterface.getParametersForFactoryFromUser(nameOfRequiredFieldsByVehicle); parametersForFactory.Add(Garage.k_LicenceNumberKey, vehicleLicenseNumber); try { io_ThisGarage.InsertNewVehicle(parametersForFactory, newVehicleType); GarageInterface.SendSucsses(); } catch (FormatException formatException) { GarageInterface.ShowThisStringAsOutput(formatException.Message); } catch (ArgumentException argumentException) { GarageInterface.ShowThisStringAsOutput(argumentException.Message); } catch (ValueOutOfRangeException outOfRangeException) { GarageInterface.ShowThisStringAsOutput(outOfRangeException.Message); } } }
public static void AskForTruckExtraInput(Garage i_Garage, ref Vehicle io_CurrentNewTruck) { bool isAllValidInput = false; while (isAllValidInput != true) { try { Console.WriteLine("Enter your trucks volume of cargo"); bool isParsed = float.TryParse(Console.ReadLine().ToString(), out float volumeOfCargo); if (isParsed == false) { Console.WriteLine(string.Format("Not a valid option")); } Console.WriteLine("Does the truck contain any hazardous materials ? y/n"); string isHazardousMaterialTruck = Console.ReadLine(); if (isHazardousMaterialTruck == "y" || isHazardousMaterialTruck == "n") { isAllValidInput = true; (io_CurrentNewTruck as Truck).UpdateNewTruckInput(isHazardousMaterialTruck, volumeOfCargo); } else { throw new ArgumentException(); } } catch (FormatException i_FormatException) { PrintFormatExceptionDecimal(); } catch (ArgumentException i_ArgumentException) { Console.WriteLine("Values must be y/n only!"); } } }
public static void ShowLicenseNumbersByStatus(Garage i_Garage) { VehicleCard.eVehicleStatus o_Status; List <String> licenseNumbersList; StringBuilder sb = new StringBuilder(); GetVehicleStatusFromUser(out o_Status); licenseNumbersList = i_Garage.GetLicenseNumbersByStatus(o_Status); if (licenseNumbersList.Count == 0) { sb.Append(string.Format("Vehicle with status {0} not found " + Environment.NewLine, o_Status.ToString())); } else { sb.Append(string.Format("Vehicles with status {0} in garage: " + Environment.NewLine, o_Status.ToString())); foreach (string licensNumber in licenseNumbersList) { sb.Append(licensNumber); } } Console.WriteLine(sb); }
public static void RefuelVehicle(Garage i_Garage) { string licenseNumToWatch = GetLicenseNumStr(); if (i_Garage.TryToFindClient(licenseNumToWatch, out ClientCard client) == true) { Vehicle vehicleToRefuel = client.VehicleInGarage; if (vehicleToRefuel.MyEngine is GasEngine) { float amountOfFuel = GetAmountOfFuelFromUser(vehicleToRefuel.MyEngine as GasEngine); GetFuelTypeFromUser(out Fuel fuelToFill, (vehicleToRefuel.MyEngine as GasEngine).MyFuel); (vehicleToRefuel.MyEngine as GasEngine).ReFuel(amountOfFuel, fuelToFill, vehicleToRefuel); Console.WriteLine("Refueled successfully"); } else { Console.WriteLine("Cannot refuel electric vehicle"); } } else { Console.WriteLine("Vehicle not found"); } }
public static void ShowAllLicenseNumbersFilter(Garage i_Garage) { int howManyCars = 0; Console.WriteLine( @"Please enter the filter for show license numbers:"); int filterType = getEnumFromUser(typeof(VehicleInformation.eVehicleCondition)); Console.WriteLine(); foreach (KeyValuePair <string, VehicleInformation> entry in i_Garage.VehiclesToFix) { if ((VehicleInformation.eVehicleCondition)filterType == entry.Value.VehicleCondition) { Console.WriteLine(entry.Key); howManyCars++; } } if (howManyCars == 0) { Console.WriteLine("There are no vehicles by this filter in the garage"); } }
internal UI() { r_Garage = new Garage(); }
public static void AskForCarExtraInput(Garage i_Garage, ref Vehicle io_CurrentNewCar) { bool isAllValid = false; while (isAllValid != true) { bool isInputValid = false; Console.WriteLine(@"Enter your car color type by precedening number - 1. Red 2. Blue 3. Grey 4. Black"); try { bool isParsed = int.TryParse(Console.ReadLine().ToString(), out int carColor); if (isParsed == false) { Console.WriteLine(string.Format("Not a valid option")); } while (isInputValid == false) { isInputValid = (carColor <= 4) && (carColor >= 1); if (isInputValid == false) { throw new ValueOutOfRangeException(4, 1); } } Console.WriteLine(@"Please enter amount of doors in the car - 2 - Two doors 3 - three doors 4 - four doors 5 - five doors"); isInputValid = false; isParsed = int.TryParse(Console.ReadLine().ToString(), out int amountOfDoors); if (isParsed == false) { Console.WriteLine(string.Format("Not a valid option")); } while (isInputValid == false) { isInputValid = (amountOfDoors <= 5) && (amountOfDoors >= 2); if (isInputValid == false) { throw new ValueOutOfRangeException(4, 1); } } (io_CurrentNewCar as Car).UpdateNewCarInput(amountOfDoors, amountOfDoors); isAllValid = true; } catch (FormatException i_FormatException) { PrintFormatExceptionDecimal(); } catch (ValueOutOfRangeException i_ValueOutOfRangeException) { Console.WriteLine(string.Format("Value must be a number between {0} - {1}!", i_ValueOutOfRangeException.MinimumValue, i_ValueOutOfRangeException.MaximumValue)); } catch (ArgumentException i_ArgumentException) { Console.WriteLine("Something went wrong.... please try to re-enter values"); } catch (NullReferenceException i_NullReferenceException) { Console.WriteLine("Something went wrong.... please try again"); } } }
public static void GarageFlow() { Garage garageOfVehicles = new Garage(); bool isQuitGarage = false; bool isDecisionOutOfRange = false; while (isDecisionOutOfRange != true) { try { int currentDecision = PrintMainMenu(); while (isQuitGarage != true) { switch (currentDecision) { case 1: EnterNewVehicleToGarage(garageOfVehicles); break; case 2: ShowAllVehicales(garageOfVehicles); break; case 3: EnterValuesForUpdateStatus(garageOfVehicles); break; case 4: PumpWheels(garageOfVehicles); break; case 5: FuelUsersVehicle(garageOfVehicles); break; case 6: ChargeUsersVehicle(garageOfVehicles); break; case 7: PrintAllVehicleData(garageOfVehicles); break; case 8: isQuitGarage = true; isDecisionOutOfRange = true; return; default: throw new ValueOutOfRangeException(8, 1); } currentDecision = PrintMainMenu(); } } catch (FormatException) { PrintFormatExceptionDecimal(); } catch (ValueOutOfRangeException i_ValueOutOfRangeException) { Console.WriteLine(string.Format("Value out of range must be between {0} - {1}", i_ValueOutOfRangeException.MinimumValue, i_ValueOutOfRangeException.MaximumValue)); } catch (ArgumentException i_ArgumentException) { Console.WriteLine(string.Format("Invalid arguments in step {0}", i_ArgumentException.StackTrace)); } PressAnyKeyToContinue(); } }
public static void ShowAllVehicales(Garage i_Garage) { int viewVehicles = 0; VehicleRecord.eVehicleStatus chosenType = 0; try { Console.WriteLine(@"Pick how you want to see the vehicles - 1. All 2. Under Repairs 3. Fixed 4. Paid for 5. Exit"); bool isParsed = int.TryParse(Console.ReadLine().ToString(), out viewVehicles); if (isParsed == false) { Console.WriteLine(string.Format("Not a valid option")); } do { switch (viewVehicles) { case 1: PrintAllLicenceNumbers(i_Garage); break; case 2: chosenType = VehicleRecord.eVehicleStatus.UnderRepairs; break; case 3: chosenType = VehicleRecord.eVehicleStatus.Fixed; break; case 4: chosenType = VehicleRecord.eVehicleStatus.PaidFor; break; case 5: Console.WriteLine("Exit succeeded."); return; default: Console.WriteLine("Not Valid... Please insert again"); isParsed = int.TryParse(Console.ReadLine().ToString(), out viewVehicles); if (isParsed == false) { Console.WriteLine(string.Format("Not a valid option")); } break; } if (chosenType != 0) { DisplayChosenVehicles(i_Garage, chosenType); } break; }while (viewVehicles != 5); } catch (FormatException i_FormatException) { Console.WriteLine("Value must be a number!"); PressAnyKeyToContinue(); } }
public App() { r_Ui = new UI(); r_Garage = new GarageLogic.Garage(); }
internal GarageAction(Garage i_Garage) { r_Garage = i_Garage; }
public static void printVehicleDetails(Garage i_Garage, string i_LicensePlate) { Console.WriteLine(i_Garage.VehiclesInTheGarage[i_LicensePlate]); }
// Public Methods public void Start() { m_Garage = new Garage(); Console.WriteLine("Hello and welcome to Garages R' Us!"); PrintMenu(); }
public static void Main() { Garage newGarage = GarageMangerUI.CreateNewGarage(); GarageMangerUI.StartGarageWorking(ref newGarage); }
public static void Run() { Garage myGarage = new Garage(); Console.WriteLine(string.Format("Welcome To The Garage!")); Garage.eGarageOptions?clientChoosement = null; string licensePlate = null; const bool k_GarageExist = true; do { Console.WriteLine(); printActionOptionsToClient(); clientChoosement = getClientChoosement(); if (clientChoosement != Garage.eGarageOptions.ShowLicensePlates) { licensePlate = GetLicensePlate(); if (clientChoosement != Garage.eGarageOptions.EnterVehicle) { if (myGarage.IsVehicleInGarage(licensePlate) == false) { Console.WriteLine("This Vehicle Is Not In The Garage."); continue; } } } switch (clientChoosement) { case Garage.eGarageOptions.EnterVehicle: { tryEnterVehicleToTheGarage(myGarage, licensePlate); break; } case Garage.eGarageOptions.ShowLicensePlates: { showLicensePlates(myGarage); break; } case Garage.eGarageOptions.ChangeVehicleStatus: { Garage.eVehicleStatus vehicleStatus = getVehicleStatus(); myGarage.ChangeVehicleStatus(licensePlate, vehicleStatus); break; } case Garage.eGarageOptions.InflateTires: { myGarage.InflateTires(licensePlate); break; } case Garage.eGarageOptions.FuelTank: { tryFuelTank(myGarage, licensePlate); break; } case Garage.eGarageOptions.ChargeElectricVehicle: { tryChargeElectricVehicle(myGarage, licensePlate); break; } case Garage.eGarageOptions.ShowVehicleDetails: { Console.WriteLine(myGarage.GetVehicleDetailsString(licensePlate)); break; } default: { break; } } }while (k_GarageExist); }
public GarageUI() { m_Garage = new Garage(); }
public static Vehicle GetNewVehicle(ref Client i_Client, ref Garage i_Garage) { Vehicle newVehicle = null; generalVehicleDetailsLabel(); string vehicleLicenseNumber = GetVehicleLicenseNumber(); if (i_Garage.IsVehicleFoundInGarage(vehicleLicenseNumber)) { Folder folder; i_Garage.GarageDataBase.TryGetValue(vehicleLicenseNumber, out folder); folder.FolderSubject.Status = Vehicle.VehicleStatus.InRepair; Console.WriteLine("Vehicle License Number {0} Existing In Garage", vehicleLicenseNumber); Console.WriteLine("Vehicle Status Chaned to {0}", Vehicle.VehicleStatus.InRepair); } else { vehicleTypeLabel(); vehicleTypesInstructionMessage(); Vehicle.VehicleType vehicleType = getVehicleType(); string vehicleModel = getVehicleModel(); short vehicleWheelsNumber = getVehicleWheelsNumber(vehicleType); EnergySystem vehicleEnergySystem = EnergySystemUI.GetNewEnergySystem(vehicleType); List <Wheel> vehicleWheels = getVehicleWheels(vehicleWheelsNumber, vehicleType); if (vehicleType == Vehicle.VehicleType.Car) { newVehicle = CarUI.GetNewCar( ref i_Client, vehicleType, vehicleModel, vehicleLicenseNumber, ref vehicleEnergySystem, vehicleWheelsNumber, ref vehicleWheels); } else if (vehicleType == Vehicle.VehicleType.Motorcycle) { newVehicle = MotorcycleUI.GetNewMotorcycle( ref i_Client, vehicleType, vehicleModel, vehicleLicenseNumber, ref vehicleEnergySystem, vehicleWheelsNumber, ref vehicleWheels); } else if (vehicleType == Vehicle.VehicleType.Truck) { newVehicle = TruckUI.GetNewTruck( ref i_Client, vehicleType, vehicleModel, vehicleLicenseNumber, ref vehicleEnergySystem, vehicleWheelsNumber, ref vehicleWheels); } else { Console.WriteLine("Bad Selection"); } } return(newVehicle); }
internal static bool checkIfValidVehicleLicenseNumAndEnergy(string i_EnergyType, out Vehicle o_Vehicle, ref Garage io_Garage) { string licenseNum; bool check = UI.getLicenseNumFromUser(out licenseNum, ref io_Garage); bool checkIfCorrectEnergyType = false; Vehicle vehicleResult = null; if (check) { VehicleInGarage vehicleInGarage = io_Garage.GetVehicleInGarage(licenseNum); vehicleResult = vehicleInGarage.GetVehicle; if ((i_EnergyType == "Fuel" && !(vehicleResult.Energy is Fuel)) || (i_EnergyType == "Electricity" && !(vehicleResult.Energy is Electricity))) { System.Console.WriteLine(@"This license number has a different energy source! Please try another vehicle license number of energy source. "); } else { check = true; checkIfCorrectEnergyType = true; } } o_Vehicle = vehicleResult; return(check && checkIfCorrectEnergyType); }
public GarageManager() { this.m_ExitGarage = false; this.m_Garage = new Garage(); }
/** * This method is a constructor for the refuel process. */ public RefuelVehicleStation(Garage i_Garage) { this.r_Garage = i_Garage; }
// C'tor public UserInterface() { this.r_Garage = new Garage(); }
public static void Main() { Garage newGarage = new Garage(); UI.Run(newGarage); }
internal GarageManager() { this.m_MyGarage = new Garage(); }
public static void NextStepVehicleMenu(Garage i_Garage, Vehicle i_Vehicle) { UserConsole outputUser = new UserConsole(); int userChoise; string licenseNumber; Vehicle vehicle; VehicleAction vehicleAction = null; bool inputAnswer = true; if (i_Vehicle != null) { while (true) { try { inputAnswer = InputValidation.GetBool("Do you want to switch vehicle?"); break; } catch (Exception ex) { UserConsole.ExceptionOutput(ex); } } if (!inputAnswer) { vehicleAction = new VehicleAction(i_Vehicle, i_Garage); } } if (inputAnswer) { while (true) { try { licenseNumber = InputValidation.GetString("Enter License number"); vehicle = i_Garage.GetVehicle(licenseNumber); break; } catch (Exception ex) { UserConsole.ExceptionOutput(ex); } } vehicleAction = new VehicleAction(vehicle, i_Garage); } while (true) { try { UserConsole.VehicleMenu(); userChoise = InputValidation.GetInt(string.Empty, 1, 6); break; } catch (Exception ex) { UserConsole.ExceptionOutput(ex); } } UserConsole.SleepAndClear(); switch (userChoise) { case 1: vehicleAction.ChangeVehicleStatus(); break; case 2: vehicleAction.FillAirWheels(); break; case 3: vehicleAction.FillFuelVehicle(); break; case 4: vehicleAction.FillElectricVehicle(); break; case 5: vehicleAction.VehicleInfo(); break; case 6: NextStepMainMenu(i_Garage); break; } }
public GarageInputManager(Garage i_Garage) { m_Garage = i_Garage; }