Clone() public method

public Clone ( ) : object
return object
Esempio n. 1
0
        // checks to see if a path is valid. used by route finding
        private bool validPath(String[] path, FlightTime start, String day, int tolerance)
        {
            Route      rte;
            FlightTime currentTime = (FlightTime)start.Clone();
            String     currentDay  = day;

            Flight[] flts;

            for (int i = 0; i < (path.Length - 1); i++)
            {
                rte = routesForParameters(path[i], path[i + 1])[0];
                if (rte.hasFlightsForTime(currentTime, currentDay, tolerance))
                {
                    flts        = rte.flightsForTime(currentTime, currentDay, tolerance);
                    currentTime = (FlightTime)flts[0].Arrival.Clone();
                    if (currentTime.nextDay)
                    {
                        currentTime.nextDay = false;
                        currentDay          = FlightTime.dayByAddingDays(day, 1);
                    }
                }
                else
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 2
0
        // returns flights that match parameters
        public Flight[] flightsForTime(FlightTime flttime, String fltday, int tolerance)
        {
            // day index, 0 is monday, etc.
            // tolerance is in minutes
            // returns null if not found

            ArrayList  flights = new ArrayList(0);
            FlightTime time    = (FlightTime)flttime.Clone();
            String     day     = (String)fltday.Clone();

            if (time.nextDay)
            {
                day          = FlightTime.dayByAddingDays(day, 1);
                time.nextDay = false;
            }

            time.addMinutes(tolerance);

            foreach (Flight flt in __flights)
            {
                if (flt.hasFlightAtTime(time, day))
                {
                    flights.Add(flt);
                }
            }

            return((Flight[])flights.ToArray(typeof(Flight)));
        }
Esempio n. 3
0
 // checks if there are flights for the parameters set
 public bool hasFlightsForTime(FlightTime time, String day, int tolerance)
 {
     if (this.flightsForTime((FlightTime)time.Clone(), day, tolerance).Length > 0)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 4
0
 // checks if there are flights for the parameters set
 public bool hasFlightsForTime(FlightTime time, String day, int tolerance)
 {
     if (this.flightsForTime((FlightTime)time.Clone(), day, tolerance).Length > 0)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
Esempio n. 5
0
        // returns flights that match parameters
        public Flight[] flightsForTime(FlightTime flttime, String fltday, int tolerance)
        {
            // day index, 0 is monday, etc.
            // tolerance is in minutes
            // returns null if not found

            ArrayList flights = new ArrayList(0);
            FlightTime time = (FlightTime)flttime.Clone();
            String day = (String)fltday.Clone();

            if (time.nextDay)
            {
                day = FlightTime.dayByAddingDays(day, 1);
                time.nextDay = false;
            }

            time.addMinutes(tolerance);

            foreach (Flight flt in __flights)
            {
                if (flt.hasFlightAtTime(time, day))
                {
                    flights.Add(flt);
                }
            }

            return (Flight[])flights.ToArray(typeof(Flight));
        }
Esempio n. 6
0
        // checks to see if a path is valid. used by route finding
        private bool validPath(String[] path, FlightTime start, String day, int tolerance)
        {
            Route rte;
            FlightTime currentTime = (FlightTime)start.Clone();
            String currentDay = day;
            Flight[] flts;

            for (int i = 0; i < (path.Length-1); i++)
            {
                rte = routesForParameters(path[i], path[i + 1])[0];
                if (rte.hasFlightsForTime(currentTime, currentDay, tolerance))
                {
                    flts = rte.flightsForTime(currentTime, currentDay, tolerance);
                    currentTime = (FlightTime)flts[0].Arrival.Clone();
                    if (currentTime.nextDay)
                    {
                        currentTime.nextDay = false;
                        currentDay = FlightTime.dayByAddingDays(day, 1);
                    }
                }
                else
                {
                    return false;
                }
            }

            return true;
        }