Esempio n. 1
0
        public Ferry NextFerryAvailableFrom(int portId, TimeSpan time)
        {
            var ports      = _portManager.PortModels();
            var allEntries = _timeTables.All().SelectMany(x => x.Entries).OrderBy(x => x.Time).ToList();

            foreach (var entry in allEntries)
            {
                var ferry = FerryManager.CreateFerryJourney(ports, entry);
                if (ferry != null)
                {
                    BoatReady(entry, ferry.Destination, ferry);
                }
                if (entry.OriginId == portId)
                {
                    if (entry.Time >= time)
                    {
                        if (ferry != null)
                        {
                            return(ferry.Ferry);
                        }
                    }
                }
            }

            return(null);
        }
Esempio n. 2
0
 // Constructor for Management System - starts all submanagers
 public ManagementSystem()
 {
     _ferryManager     = new FerryManager();
     _timeTableManager = new TimeTableManager();
     _portManager      = new PortManager();
     _bookingManager   = new BookingManager();
     _journeyManager   = new JourneyManager();
 }
Esempio n. 3
0
        private static void BoatReady(TimeTableEntry timetable, PortModel destination, FerryJourney ferryJourney)
        {
            if (ferryJourney.Ferry == null)
            {
                FerryManager.AddFerry(timetable, ferryJourney);
            }

            var ferry = ferryJourney.Ferry;

            var time = FerryModule.TimeReady(timetable, destination);

            destination.AddBoat(time, ferry);
        }
Esempio n. 4
0
        public static TimeSpan TimeReady(TimeTableEntry timetable, PortModel destination)
        {
            if (timetable == null)
            {
                return(new TimeSpan(0, 0, 0));
            }
            if (destination == null)
            {
                throw new ArgumentNullException("destination");
            }

            var arrivalTime    = timetable.Time.Add(timetable.JourneyTime);
            int turnaroundTime = FerryManager.GetFerryTurnaroundTime(destination);
            var timeReady      = arrivalTime.Add(TimeSpan.FromMinutes(turnaroundTime));

            return(timeReady);
        }