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 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; } }
private float setElectric(Vehicle i_Vehicle) { float energyAmount = 0; while (true) { try { ElectricEngine ElectricEngine = i_Vehicle.Engine as ElectricEngine; UserConsole.SleepAndClear(); energyAmount = InputValidation.GetFloat("\nEnter amount of minutes of energy you want to fill: "); ElectricEngine.FillEnergy(energyAmount); break; } catch (Exception ex) { UserConsole.ExceptionOutput(ex); } } return(energyAmount); }
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); }
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; } }
private void endAction() { UserConsole.SleepAndClear(); MenuToUser.NextStepMainMenu(r_Garage); }
private void endAction() { UserConsole.SleepAndClear(); MenuToUser.NextStepVehicleMenu(r_Garage, r_Vehicle); }