Example #1
0
        public Route(String xml)
        {
            this.__flights = new ArrayList(0);

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xml);

            XmlElement head = doc.DocumentElement;
            foreach (XmlAttribute attr in head.Attributes)
            {
                if (attr.Name.ToLower().Equals("origin"))
                {
                    this.origin = attr.Value;
                }
                else if (attr.Name.ToLower().Equals("destination"))
                {
                    this.destination = attr.Value;
                }
            }

            Flight newFlight;
            XmlNodeList flights = head.SelectNodes("/Route/Flight");
            foreach (XmlNode flight in flights)
            {
                newFlight = new Flight(flight.OuterXml, this);
                this.__flights.Add(newFlight);
                newFlight = null;
            }
        }
Example #2
0
        public Flight[] connectingForFlight(Flight flight, String nextDest, String day, int tolerance)
        {
            ArrayList flights = new ArrayList(0);
            Route[] connectingRoutes = routesForParameters(flight.Route.Destination, nextDest);

            foreach (Route route in connectingRoutes)
            {
                flights.AddRange(route.flightsForTime(flight.Arrival, day, tolerance));
            }

            return (Flight[])flights.ToArray(typeof(Flight));
        }
Example #3
0
        public ArrayList flightsForRoute(Route[] routes, FlightTime start, String day, int tolerance)
        {
            ArrayList flights = new ArrayList(0);

            if (routes.Length == 1)
            {
                Flight[] test;
                foreach (Flight flt in routes[0].Flights)
                {
                    test = new Flight[] { flt };
                    flights.Add(test);
                }

            }
            else if (routes.Length > 1)
            {
                // do the tree thing
                TreeNode<Flight> root = flightsTree(routes, start, day, tolerance);
                Stack<Flight> stack = new Stack<Flight>(0);

                buildFlightsArray(root, ref stack, ref flights);
            }

            return flights;
        }
Example #4
0
 public Flight[] connectingForFlight(Flight flight, String day, int tolerance)
 {
     return connectingForFlight(flight, "", day, tolerance);
 }