コード例 #1
0
        private void GetDepartures(string[] args)
        {
            string crsFrom, crsTo;

            if (args[0] == "departing" || args[0] == "dep")
            {
                crsFrom = args[1];
                crsTo   = args[2];
            }
            else
            {
                crsFrom = args[0];
                crsTo   = args[1];
            }

            var departures = _service.GetTrainsTo(crsFrom, crsTo);

            if (departures == null)
            {
                Console.WriteLine("No trains were found.");
                return;
            }
            Console.WriteLine($"There are {departures.Count()} total departures from {crsFrom.ToUpper()} to {crsTo.ToUpper()}.\n");
            var times = departures.Select(d => $"{d.std} ({d.etd}) - Platform {d.platform ?? "Unknown"}");

            Console.WriteLine(string.Join(Environment.NewLine, times));
        }