// fill gas for an existing suitable type vehicle internal void FillGas(GarageLogic.Garage i_Garage) { // gets license number and checks if exist in garage, if not may exit to main menu m_CurrentLicnese = GetLicense(i_Garage); if (m_CurrentLicnese.Equals("-1")) { return; } int numberOfChoice = 1; Dictionary <string, GarageLogic.FuelEngine.eFuelType> fuelTypes = new Dictionary <string, FuelEngine.eFuelType>(); // checks and validate amount of gas to refill Console.WriteLine("Please enter amount of Litres to add"); string litres = Console.ReadLine(); float litresToAdd = 0; bool isLitres = float.TryParse(litres, out litresToAdd); while (!isLitres) { Console.WriteLine("Please enter minutes as float number"); litres = Console.ReadLine(); isLitres = float.TryParse(litres, out litresToAdd); } Console.WriteLine("Please pick one of the Fuel types below: "); // iterate through gas types available and prints them foreach (GarageLogic.FuelEngine.eFuelType type in Enum.GetValues(typeof(GarageLogic.FuelEngine.eFuelType))) { Console.WriteLine(numberOfChoice + ". " + type.ToString()); fuelTypes.Add(numberOfChoice.ToString(), type); numberOfChoice++; } numberOfChoice--; // sets and validate the type of fuel to refill string statusPicked = Console.ReadLine(); while (!ValidtysUI.CheckMainPickValidity(statusPicked, 1, numberOfChoice)) { Console.WriteLine("Illegal input, Please pick a number between 1 to " + numberOfChoice); statusPicked = Console.ReadLine(); } // try refuel vehicle, if vehicle is not suitable, brings back to main menu try { i_Garage.FillUpGas(m_CurrentLicnese, fuelTypes[statusPicked], litresToAdd); } catch (ArgumentException e) { Console.WriteLine(e.Message); Thread.Sleep(1500); return; } catch (Exception e) { Console.WriteLine(e.Message); Thread.Sleep(1500); return; } // show success message and takes back to main menu SuccessFinishOperation(); }