internal void ShowVehiclesWithFilter() { VehicleGarageInfo.eVehicleCondition vehicleCondition; while (true) { try { vehicleCondition = (VehicleGarageInfo.eVehicleCondition)InputValidation.EnumChoiseToInt(typeof(VehicleGarageInfo.eVehicleCondition), UserConsole.ChooseString("vehicle condition")); UserConsole.Print(string.Format("All vehicles in the garage that are {0}:", vehicleCondition.ToString())); UserConsole.Print(r_Garage.VehicleInGarageToString(vehicleCondition)); break; } catch (Exception ex) { UserConsole.ExceptionOutput(ex); } finally { UserConsole.PrintAndRead("Press any key to go back to vehicle menu"); endAction(); } } endAction(); }
internal void AddVehicleToGarage() { Vehicle vehicle; VehicleCreater.eVehicleTypes vehicleType; while (true) { try { vehicleType = (VehicleCreater.eVehicleTypes)InputValidation.EnumChoiseToInt(typeof(VehicleCreater.eVehicleTypes), UserConsole.ChooseString("vehicle type")); vehicle = VehicleCreater.InitVehicle(vehicleType); vehicle.LicenseNumber = InputValidation.GetString("\nEnter License number: "); vehicle.ModelName = InputValidation.GetString("\nEnter model Name: "); r_Garage.AddVehicleToGarage(vehicle); break; } catch (Exception ex) { UserConsole.ExceptionOutput(ex); } } vehicle.VehicleInfo = setVehicleInfo(); setEnergy(vehicle); UserConsole.SleepAndClear(); setWheelInfo(vehicle); UserConsole.Print("\n"); setExtraDeatails(vehicle); UserConsole.Print("\nVehicle was added successfully!"); endAction(); }
public static int GetPositiveInt(string i_Msg) { string stringInput; UserConsole.Print(i_Msg); stringInput = UserConsole.Read(); return(parseInt(stringInput)); }
public static string GetString(string i_Msg) { string stringInput; UserConsole.Print(i_Msg); stringInput = UserConsole.Read(); if (stringInput.Length == 0) { throw new Exception("Please enter a string"); } else { return(stringInput); } }
public static string GetStringNumber(string i_Msg) { string stringInput; bool isNumber; int number = 0; UserConsole.Print(i_Msg); stringInput = UserConsole.Read(); isNumber = int.TryParse(stringInput, out number); if (!isNumber || number < 0) { throw new ArgumentException("The input is not a number"); } return(stringInput); }
internal void ShowAllVehicles() { try { UserConsole.Print("All vehicals in the garage: \n"); UserConsole.Print(r_Garage.VehicleInGarageToString()); } catch (Exception ex) { UserConsole.ExceptionOutput(ex); } finally { UserConsole.PrintAndRead("Press any key to go back to vehicle menu"); endAction(); } }
internal void FillAirWheels() { while (true) { try { r_Garage.FillAirToMax(r_Vehicle.LicenseNumber); break; } catch (Exception ex) { UserConsole.ExceptionOutput(ex); } } UserConsole.Print("Filling air finished!"); endAction(); }
public static void NextStepMainMenu(Garage i_Garage) { UserConsole outputUser = new UserConsole(); GarageAction garageAction = new GarageAction(i_Garage); int userChoise; UserConsole.MainMenu(); while (true) { try { userChoise = InputValidation.GetInt(string.Empty, 1, 5); break; } catch (Exception ex) { UserConsole.Print(ex.Message); } } UserConsole.SleepAndClear(); switch (userChoise) { case 1: garageAction.AddVehicleToGarage(); break; case 2: garageAction.ShowAllVehicles(); break; case 3: garageAction.ShowVehiclesWithFilter(); break; case 4: NextStepVehicleMenu(i_Garage, null); break; case 5: System.Environment.Exit(0); break; } }
public static bool GetBool(string i_Msg) { string inputString; bool result = true; UserConsole.Print(i_Msg); UserConsole.Print("Enter 0 for no, 1 for yes."); inputString = UserConsole.Read(); if (!inputString.Equals("1") && !inputString.Equals("0")) { throw new Exception("You didnt enter 0 or 1"); } else if (inputString.Equals("0")) { result = false; } return(result); }
public static float GetFloat(string i_Msg) { string stringInput; float o_InputNumber = 0; bool isNumber; UserConsole.Print(i_Msg); stringInput = UserConsole.Read(); isNumber = float.TryParse(stringInput, out o_InputNumber); if (!isNumber) { throw new FormatException("The input is not a number"); } else if (o_InputNumber < 0) { throw new Exception("The input is not a positive number"); } else { return(o_InputNumber); } }
public static int EnumChoiseToInt(Type i_EnumType, string i_msg) { string userInput; string msg; int userChoise; int minChoise = 1; int maxChoise; UserConsole.SleepAndClear(); UserConsole.Print(i_msg); UserConsole.Print(UserConsole.EnumToString(i_EnumType)); userInput = UserConsole.Read(); userChoise = parseInt(userInput); maxChoise = Enum.GetNames(i_EnumType).Length; if ((userChoise < minChoise) || (userChoise > maxChoise)) { throw new ValueOutOfRangeException((float)minChoise, (float)maxChoise); } msg = string.Format(@"You choose {0}", userChoise); UserConsole.Print(msg); return(userChoise); }
private float setFuel(Vehicle i_Vehicle) { FuelEngine.eFuelType fuelType; float fuelAmount = 0; while (true) { try { FuelEngine fuelEngine = i_Vehicle.Engine as FuelEngine; UserConsole.Print("\nLets fill up Fuel!"); fuelType = (FuelEngine.eFuelType)InputValidation.EnumChoiseToInt(typeof(FuelEngine.eFuelType), UserConsole.ChooseString("fuel type")); fuelAmount = InputValidation.GetFloat("\nEnter amount of fuel you want to fill: "); fuelEngine.FillFuel(fuelType, fuelAmount); break; } catch (Exception ex) { UserConsole.ExceptionOutput(ex); } } return(fuelAmount); }
internal void VehicleInfo() { UserConsole.Print(r_Garage.VehicleInfo(r_Vehicle.LicenseNumber)); UserConsole.PrintAndRead("\nPress any key to go back to vehicle menu"); endAction(); }
internal void StartGarageApp() { UserConsole.Print("\n\t\t\t░W░e░l░c░o░m░e░ ░t░o░ ░t░h░e░ ░G░A░R░A░G░E░\n"); MenuToUser.NextStepMainMenu(r_Garage); }