Example #1
0
        // Display Time Table Command - Displays the time table
        private static void DisplayTimeTableCommand()
        {
            try
            {
                Console.WriteLine("Ferry Time Table:");
                Console.WriteLine("-----------------");

                foreach (var port in ManagementSystem.GetAllPorts())
                {
                    PrintPortHeader(port.Name);

                    // Every Journey is based on an entry in the timetable, use them to display timetable
                    foreach (var journey in ManagementSystem.GetAllJourneys().OrderBy(x => x.Origin.Name).ThenBy(x => x.Departure))
                    {
                        if (journey.Origin.Id == port.Id)
                        {
                            Console.WriteLine("| {0} | {1} | {2} | {3} | {4} |",
                                              journey.Departure.ToString().PadRight(8),
                                              journey.Destination.Name.PadRight(13),
                                              journey.Travel.ToString().PadRight(13),
                                              journey.Ferry.Name.PadRight(18),
                                              journey.Arrival.ToString().PadRight(8)
                                              );
                        }
                    }
                }
            }
            catch (Exception)
            {
                DisplayTimeTableError();
            }
        }
Example #2
0
        // Creates a list of journeys to travel on
        private static void CreateJourneys()
        {
            var timetable = ManagementSystem.GetFullTimeTable().OrderBy(x => x.Time).ThenBy(x => x.OriginId);
            var ports     = ManagementSystem.GetAllPorts();

            foreach (var entry in timetable)
            {
                Port    fromPort = ports.Where(x => x.Id == entry.OriginId).Single();
                Port    toPort   = ports.Where(x => x.Id == entry.DestinationId).Single();
                Ferry   ferry    = ManagementSystem.GetNextAvailableFerry(fromPort, toPort, entry.Time);
                Journey journey  = new Journey
                {
                    Id          = entry.Id,
                    Origin      = fromPort,
                    Destination = toPort,
                    Departure   = entry.Time,
                    Travel      = entry.JourneyTime,
                    Arrival     = entry.Time + entry.JourneyTime,
                    Ferry       = ferry,
                    Seats       = ferry.Passengers,
                    Vehicles    = ferry.Vehicles,
                    Weight      = ferry.Weight
                };

                _journeys.Add(journey);
                ManagementSystem.SetFerryJourney(ferry, journey);
                ManagementSystem.MoveFerry(entry.OriginId, entry.DestinationId, ferry);
            }
        }
Example #3
0
 // List Ports Command  - Displays all ports
 private static void ListPortsCommand()
 {
     try
     {
         Console.WriteLine("Ports:");
         Console.WriteLine("------");
         foreach (var port in ManagementSystem.GetAllPorts())
         {
             Console.WriteLine("Port {0} - {1}", port.Id, port.Name);
         }
     }
     catch (Exception)
     {
         ListPortError();
     }
 }