private Vehicle createNewVehicle(string i_UserPlateNumber) { bool isVehicleTypeValid = false; Vehicle newVehicle; VehicleFactory.eVehicleType newVehicleType = VehicleFactory.eVehicleType.FuelCar; string userChoice; Console.WriteLine("{0}Please Enter the following information: {0}", Environment.NewLine); this.printMultiChoiceList(VehicleFactory.VehicleTypeKey, Enum.GetNames(typeof(VehicleFactory.eVehicleType))); this.printEnterChoiceMsg(); do { try { userChoice = Console.ReadLine(); newVehicleType = LogicUtils.EnumValidation <VehicleFactory.eVehicleType>(userChoice, VehicleFactory.VehicleTypeKey); isVehicleTypeValid = true; } catch (Exception exception) { Console.WriteLine(exception.Message); } }while (!isVehicleTypeValid); newVehicle = VehicleFactory.CreateVehicle(i_UserPlateNumber, newVehicleType); this.setVehicleInfo(newVehicle, newVehicleType); return(newVehicle); }
private void refuelVehicle(string i_PlateNumber) { this.printMultiChoiceList(FuelEnergy.FuelTypeKey, Enum.GetNames(typeof(FuelEnergy.eFuelType))); this.printEnterChoiceMsg(); string i_Choice = Console.ReadLine(); try { FuelEnergy.eFuelType fuelTypeChosen = LogicUtils.EnumValidation <FuelEnergy.eFuelType>(i_Choice, FuelEnergy.FuelTypeKey); float amountToAdd = this.getAmountOfUnitsToAdd(FuelEnergy.FuelUnits); this.m_Garage.RefuelFuelVehicle(i_PlateNumber, fuelTypeChosen, amountToAdd); Console.WriteLine("The vehicle with license plate: {0} was refueled successfuly!", i_PlateNumber); } catch (Exception exception) { Console.WriteLine(exception.Message); } }
private eUserChoice getUserChoice() { eUserChoice userChoice = eUserChoice.ExitProgram; string userChoiceStr; bool isValidInput = false; do { try { this.printEnterChoiceMsg(); userChoiceStr = Console.ReadLine(); userChoice = LogicUtils.EnumValidation <eUserChoice>(userChoiceStr, k_UserChoiceKey); isValidInput = true; } catch (Exception exception) { Console.WriteLine(exception.Message); } }while (!isValidInput); return(userChoice); }