Exemple #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();
                    }
                }
            }
        }
Exemple #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)));
        }
Exemple #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);
        }
Exemple #4
0
 public void ListAirports()
 {
     commandLine.Write("List of Airports:");
     foreach (var airport in airportStore.Airports)
     {
         commandLine.Write(airport.ToString());
     }
 }
Exemple #5
0
        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());
     }
 }
Exemple #7
0
 public void DisplayApplicationName()
 {
     commandLine.Write("Airport.");
 }
Exemple #8
0
        public void ListFlights()
        {
            commandLine.Write("Available flights:");

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