public void DisplayAllVehiclesInCurrentStatus(GarageLogicManager i_GarageInstance) { int i = 0; askUserForVehicleStatus(); int[] vehicleStatusToDisplay = new int[Enum.GetNames(typeof(Vehicle.eGarageStatus)).Length]; string choosenOption = Console.ReadLine(); foreach (char option in choosenOption) { if (char.IsDigit(option)) { vehicleStatusToDisplay[i++] = (int)char.GetNumericValue(option); } else { if (option != ' ') { throw new FormatException("enter only digits according to the option that was given"); } } } Console.WriteLine(i_GarageInstance.GetListOfVehicleByStatus(vehicleStatusToDisplay)); }
private void displayAllInformationOfSpecifiedVehicle(GarageLogicManager i_GarageInstance) { Console.WriteLine("Enter the serial of the car which you want to display all information of"); string carSerial = Console.ReadLine(); Vehicle toBeDisplayed = null; bool vehicleExists = i_GarageInstance.GarageDictionary.TryGetValue(carSerial, out toBeDisplayed); Console.WriteLine(toBeDisplayed.ToString()); }
private void inflateCarsWheelsToMaximum(GarageLogicManager i_GarageInstance) { Console.WriteLine("Enter the 'Serial' of the vehicle which you want to inflate it's wheels"); string carSerial = Console.ReadLine(); try { i_GarageInstance.InflateWheels(carSerial); } catch (Exception carDoesntExistException) { Console.WriteLine(carDoesntExistException); } }
private void changeACarsStatus(GarageLogicManager i_GarageInstance) { Console.WriteLine("Enter the 'Serial' of the vehicle which you want to inflate it's wheels"); string carSerial = Console.ReadLine(); Console.WriteLine("Please enter the new status of the vehicle (InRepair, Repaired, RepairedAndPaid): "); string userInput = Console.ReadLine(); try { i_GarageInstance.ChangeStatus(carSerial, userInput); } catch (ArgumentException badArgumentException) { Console.WriteLine(badArgumentException.Message); } }
private void chargeACarWithElectricity(GarageLogicManager i_GarageInstance) { Console.WriteLine("Enter the 'Serial' of the vehicle which you want to charge"); string carSerial = Console.ReadLine(); Console.WriteLine("Enter amount of minutes to charge into the vehicle"); string minutesAmount = Console.ReadLine(); try { i_GarageInstance.ChargeElectricity(carSerial, minutesAmount); } catch (FormatException parseFailException) { Console.WriteLine(parseFailException); } catch (Exception otherException) { Console.WriteLine(otherException); } }
private void enterNewVehicle(GarageLogicManager i_GarageInstance) { bool codeSectionCompleted = false; VehicleCreator.eVehicleTypes chosenVehicleOption = letUserChooseCarOption();; if (Enum.IsDefined(typeof(VehicleCreator.eVehicleTypes), chosenVehicleOption)) { Console.WriteLine("Please enter vehicle serial:"); string carSerialInput = Console.ReadLine(); Vehicle toEnterVehicle = null; if (i_GarageInstance.GarageDictionary.TryGetValue(carSerialInput, out toEnterVehicle)) { } else { toEnterVehicle = VehicleCreator.CreateVehicle(chosenVehicleOption); i_GarageInstance.GarageDictionary.Add(carSerialInput, toEnterVehicle); } setBaseProperties(toEnterVehicle, carSerialInput); setRequiredInputs(toEnterVehicle); } }
private void fillPetrolToAVehicle(GarageLogicManager i_GarageInstance) { Console.WriteLine("Enter the 'Serial' of the vehicle which you want to petrol in"); string carSerial = Console.ReadLine(); Console.WriteLine("Enter the type of petrol to fill"); string petrolType = Console.ReadLine(); Console.WriteLine("Enter amount of petrol to fill"); float petrolAmount = float.Parse(Console.ReadLine()); try { i_GarageInstance.FillPetrol(carSerial, petrolType, petrolAmount); } catch (FormatException parseFailException) { Console.WriteLine(parseFailException); } catch (Exception relevantError) { Console.WriteLine(relevantError); } }
public void GarageManager() { bool managerIsActive = true; GarageLogicManager garageInstance = GarageLogicManager.Garage; while (managerIsActive) { eMenuOptions chosenCase = getOptionInput(); switch (chosenCase) { case eMenuOptions.EnterNewVehicle: { enterNewVehicle(garageInstance); break; } case eMenuOptions.DisplayAllVehiclesByAttribute: { DisplayAllVehiclesInCurrentStatus(garageInstance); break; } case eMenuOptions.ChangeCarStatus: { changeACarsStatus(garageInstance); break; } case eMenuOptions.InflateWheelsToMaximum: { inflateCarsWheelsToMaximum(garageInstance); break; } case eMenuOptions.FillPetrolToVehicle: { fillPetrolToAVehicle(garageInstance); break; } case eMenuOptions.ChargeElectricVehicle: { chargeACarWithElectricity(garageInstance); break; } case eMenuOptions.DisplayAllInfoOfVehicle: { displayAllInformationOfSpecifiedVehicle(garageInstance); break; } case eMenuOptions.ExitProgram: { managerIsActive = false; break; } default: { Console.WriteLine("Invalid menu option"); break; } } } }
public GarageManager() { r_Garage = new GarageLogicManager(); }