Ejemplo n.º 1
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);
            }
        }
 public void AddBoat(TimeSpan available, Ferry boat)
 {
     if (boat != null)
     {
         _boats.Add(boat);
         _boatAvailability.Add(boat.Id, available);
     }
 }
 public void AddBoat(TimeSpan available, Ferry boat)
 {
     if (boat != null)
     {
         _boats.Add(boat);
         _boatAvailability.Add(boat.Id, available);
     }
 }
Ejemplo n.º 4
0
 public void AddFerry(TimeSpan available, Ferry ferry)
 {
     if (ferry != null)
     {
         _ferries.Add(ferry);
         _ferryAvailability.Add(ferry.Id, available);
     }
 }
Ejemplo n.º 5
0
        // Move a ferry to a new port
        public void MoveFerry(Ferry ferry, int originId, int destinationId)
        {
            Port oldPort = _ports.Find(x => x.Id == originId);

            oldPort.Ferries.Remove(ferry);
            Port newPort = _ports.Find(x => x.Id == destinationId);

            newPort.Ferries.Add(ferry);
        }
Ejemplo n.º 6
0
 // Sets a ferry on a journey
 public void SetFerryJourney(Ferry ferry, Journey journey)
 {
     ferry.Journey = journey;
 }
Ejemplo n.º 7
0
 // Set a ferry on a journey
 public static void SetFerryJourney(Ferry ferry, Journey journey)
 {
     _ferryManager.SetFerryJourney(ferry, journey);
 }
Ejemplo n.º 8
0
 // Send a ferry to a new port
 public static void MoveFerry(int originId, int destinationId, Ferry ferry)
 {
     _portManager.MoveFerry(ferry, originId, destinationId);
 }