public void Run() { RegisterCommands(); cli.DisplayApplicationName(); while (true) { commandLine.Write("Available sections: model, airplane, airport, flight, exit"); commandLine.Write("What do you want to do next:"); string help = commandLine.Read(); if (help.ToLower() == "exit") { Exit(); } else { if (cli.ReturnCommand(help.ToLower())) { cli.HandleCommand(help.ToLower()); } else { cli.DisplayHelp(help); cli.HandleCommand(); } } } }
public TimeSpan GetTravelTime(string cityOfDeparture, string cityOfArrival, double averageSpeedKmH) { var loacationElementDeparture = GetLocation(cityOfDeparture); if (loacationElementDeparture == null) { commandLine.Write("Returning a test travel time: 3 hours."); return(TimeSpan.FromHours(3)); } var loacationElementArrival = GetLocation(cityOfArrival); if (loacationElementArrival == null) { commandLine.Write("Returning a test travel time: 3 hours."); return(TimeSpan.FromHours(3)); } var distance = GetDistance(loacationElementDeparture, loacationElementArrival) / 1000; return(TimeSpan.FromHours(Math.Round(distance / averageSpeedKmH, 2))); }
public static int ReadInt(this ICommandLine commandLine, string message, bool allowEmpty = false) { int value = 0; string input; do { commandLine.Write(message); input = commandLine.Read(); if (allowEmpty && string.IsNullOrWhiteSpace(input)) { break; } }while (!int.TryParse(input, out value) || value == 0); return(value); }
public void ListAirports() { commandLine.Write("List of Airports:"); foreach (var airport in airportStore.Airports) { commandLine.Write(airport.ToString()); } }
public void ListAirplanes() { commandLine.Write("Availible airplanes:"); foreach (var airplane in airplaneStore.Airplanes) { commandLine.Write(airplane.ToString()); } }
public void ListModels() { commandLine.Write("Available aircraft models:"); foreach (var aircraftModel in store.Models) { commandLine.Write(aircraftModel.ToString()); } }
public void DisplayApplicationName() { commandLine.Write("Airport."); }
public void ListFlights() { commandLine.Write("Available flights:"); foreach (var flight in flightStore.Flights) { commandLine.Write(flight.ToString()); } }