private eMenuKeyOption getKeyMenuInput() { int optionAsInt = 0; bool isInputValid = false; int howManyMenuOptions = Enum.GetNames(typeof(eMenuKeyOption)).Length; while (isInputValid == false) { string optionSelectedAsString = Console.ReadLine(); isInputValid = checkMenuOptionSelectedThenPrintCheckAndReturnAsInteger( optionSelectedAsString, howManyMenuOptions, out optionAsInt); } eMenuKeyOption optionSelected = 0; foreach (eMenuKeyOption menuOption in Enum.GetValues(typeof(eMenuKeyOption))) { if ((int)menuOption == optionAsInt) { optionSelected = menuOption; } } return(optionSelected); }
public void StartManageGarage() { while (m_IsManagerStillInTheGarage == true) { printMessageToConsole(eMessageToPrint.MenuHeadline); showMenu(); eMenuKeyOption menuKeyOption = getKeyMenuInput(); navigateToAction(menuKeyOption); } }
private void printMenuOptionToConsole(eMenuKeyOption i_MenuOptionToPrint) { const string k_Format = "D"; StringBuilder menuOptionToPrint = new StringBuilder(); switch (i_MenuOptionToPrint) { case eMenuKeyOption.AddVehicleToGarage: menuOptionToPrint.AppendFormat("{0}. Add Vehicle To Garage.", eMenuKeyOption.AddVehicleToGarage.ToString(k_Format)); break; case eMenuKeyOption.ShowLicenseNumbersOfClientVehicles: menuOptionToPrint.AppendFormat("{0}. Show License Numbers Of Client Vehicles.", eMenuKeyOption.ShowLicenseNumbersOfClientVehicles.ToString(k_Format)); break; case eMenuKeyOption.ChangeClientVehicleStatus: menuOptionToPrint.AppendFormat("{0}. Change Client Vehicle Status.", eMenuKeyOption.ChangeClientVehicleStatus.ToString(k_Format)); break; case eMenuKeyOption.InflateVehicleTiresToMaximum: menuOptionToPrint.AppendFormat("{0}. Inflate Vehicle Tires To Maximum.", eMenuKeyOption.InflateVehicleTiresToMaximum.ToString(k_Format)); break; case eMenuKeyOption.RefuelVehicle: menuOptionToPrint.AppendFormat("{0}. Refuel Vehicle.", eMenuKeyOption.RefuelVehicle.ToString(k_Format)); break; case eMenuKeyOption.RechargeVehicle: menuOptionToPrint.AppendFormat("{0}. Recharge Vehicle.", eMenuKeyOption.RechargeVehicle.ToString(k_Format)); break; case eMenuKeyOption.ShowClientVehicleInformation: menuOptionToPrint.AppendFormat("{0}. Show Client Vehicle Information.", eMenuKeyOption.ShowClientVehicleInformation.ToString(k_Format)); break; case eMenuKeyOption.ExitMenu: menuOptionToPrint.AppendFormat("{0}. Exit Menu", eMenuKeyOption.ExitMenu.ToString(k_Format)); break; default: printMessageToConsole(eMessageToPrint.InvalidMenuKey); break; } Console.WriteLine(menuOptionToPrint); }
private void navigateToAction(eMenuKeyOption i_MenuKeyOption) { switch (i_MenuKeyOption) { case eMenuKeyOption.AddVehicleToGarage: addVehicleToGarage(); //TODO: BIG PROBLEM! break; case eMenuKeyOption.ShowLicenseNumbersOfClientVehicles: showLicenseNumbersOfClientVehicles(); break; case eMenuKeyOption.ChangeClientVehicleStatus: changeClientVehicleStatus(); break; case eMenuKeyOption.InflateVehicleTiresToMaximum: inflateVehicleTiresToMaximum(); break; case eMenuKeyOption.RefuelVehicle: refuelVehicle(); break; case eMenuKeyOption.RechargeVehicle: rechargeVehicle(); break; case eMenuKeyOption.ShowClientVehicleInformation: showClientVehicleInformation(); break; case eMenuKeyOption.ExitMenu: exitMenu(); break; } }