/*** Options 3 - 7 ***/ private void menuOptions(int i_MainMenuSelection) { int userChoice; System.Console.Clear(); string licenseNumber; Vehicle currentVehicle = this.promptUserForLicenseNumber(out licenseNumber); if (currentVehicle != null) { switch (i_MainMenuSelection) { case 3: /* 3) Change a vehicle status */ System.Console.WriteLine(createMenuStringFromEnum(typeof(Vehicle.eVehicleStatus), "Enter a Vehicle Status")); userChoice = promptUserForMenuSelection(Enum.GetNames(typeof(Vehicle.eVehicleStatus)).Length); try { m_Garage.ChangeVehicleStatus(licenseNumber, (Vehicle.eVehicleStatus)(userChoice - 1)); string vehicleStatusMessage = string.Format(@"The status of this vehicle is now: {0} ", (Vehicle.eVehicleStatus)(userChoice - 1)); } catch (ArgumentException ex) { Console.WriteLine(ex.ToString()); } break; case 4: /* 4) Inflate tires to max */ currentVehicle.InflateAllWheelsToMax(); System.Console.Clear(); System.Console.WriteLine("Inflation of tires succesful."); //System.Console.WriteLine(Environment.NewLine); break; case 5: /* 5) Refuel vehicle */ FuelBasedEngine fuelEngine = currentVehicle.Engine as FuelBasedEngine; if (fuelEngine == null) { try { throw new FormatException(); } catch (FormatException) { Console.WriteLine("This vehicle does not have a fuel based engine. Refuel Failed"); System.Console.WriteLine(Environment.NewLine); } } else { System.Console.WriteLine(createMenuStringFromEnum(typeof(FuelBasedEngine.eFuelType), "Enter a Fuel Type")); userChoice = this.promptUserForMenuSelection(Enum.GetNames(typeof(FuelBasedEngine.eFuelType)).Length); string refuelMessage = string.Format(@"Current Amount Of Fuel: {0} Maximum Amount Of Fuel: {1} Please enter amount to refuel:", fuelEngine.CurrentAmountOfFuel, fuelEngine.MaxAmountOfFuel); System.Console.WriteLine(refuelMessage); float amountToRefuel = this.getFloatFromUser(0, fuelEngine.MaxAmountOfFuel - fuelEngine.CurrentAmountOfFuel); try { this.m_Garage.RefuelVehicle(licenseNumber, (FuelBasedEngine.eFuelType)(userChoice - 1), amountToRefuel); System.Console.WriteLine("Refuel Succesful."); } catch (ArgumentException) { string fuelTypeExceptionMessage = string.Format("Wrong fuel type for this vehicle, expected {0}. Refuel Failed.", fuelEngine.FuelType); Console.WriteLine(fuelTypeExceptionMessage); } System.Console.WriteLine(Environment.NewLine); } break; case 6: /* 6) charge vehicle */ ElectricBasedEngine electricEngine = currentVehicle.Engine as ElectricBasedEngine; if (electricEngine == null) { try { throw new FormatException(); } catch (FormatException) { System.Console.WriteLine("This vehicle does not have an electric based engine. Recharge Failed."); } } string rechargeMessage = string.Format(@"Remaining time of engine operation in hours: {0} Max time of engine operations in hours: {1} Please enter number of minutes to recharge:", electricEngine.RemainingTimeOnBattery, electricEngine.MaxBatteryLife); System.Console.WriteLine(rechargeMessage); float amountToRecharge = this.getFloatFromUser(0, (electricEngine.MaxBatteryLife - electricEngine.RemainingTimeOnBattery) * 60); m_Garage.ChargeElectricVehice(licenseNumber, amountToRecharge); System.Console.WriteLine("Recharge Succesful."); System.Console.WriteLine(Environment.NewLine); break; case 7: /* 7) Display vehicle information */ System.Console.Clear(); System.Console.WriteLine(currentVehicle.ToString()); System.Console.WriteLine(Environment.NewLine); break; } } else { System.Console.WriteLine(string.Format("Vehicle with licence number {0} is not in the garage.{1}", licenseNumber, Environment.NewLine)); } returnToMenuOrQuit(); }