示例#1
0
        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();
                    }
                }
            }
        }
示例#2
0
        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)));
        }
示例#3
0
        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);
        }
示例#4
0
 public void ListAirports()
 {
     commandLine.Write("List of Airports:");
     foreach (var airport in airportStore.Airports)
     {
         commandLine.Write(airport.ToString());
     }
 }
示例#5
0
        public void ListAirplanes()
        {
            commandLine.Write("Availible airplanes:");

            foreach (var airplane in airplaneStore.Airplanes)
            {
                commandLine.Write(airplane.ToString());
            }
        }
示例#6
0
 public void ListModels()
 {
     commandLine.Write("Available aircraft models:");
     foreach (var aircraftModel in store.Models)
     {
         commandLine.Write(aircraftModel.ToString());
     }
 }
示例#7
0
 public void DisplayApplicationName()
 {
     commandLine.Write("Airport.");
 }
示例#8
0
        public void ListFlights()
        {
            commandLine.Write("Available flights:");

            foreach (var flight in flightStore.Flights)
            {
                commandLine.Write(flight.ToString());
            }
        }