// 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); } }
// Assign a time table to a port private void PortTimeTable() { foreach (var port in _ports) { foreach (var entry in ManagementSystem.GetFullTimeTable()) { if (entry.TimeTableId == port.Id) { entry.OriginId = entry.TimeTableId; port.TimeTable.Add(entry); } } } }