indexForDay() public static method

public static indexForDay ( String day ) : int
day String
return int
Beispiel #1
0
        public Flight(String xml, Route route)
        { // xml parser for flight details
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);

            XmlElement head = doc.DocumentElement;

            this.flightNo = head.GetAttribute("no");

            this.route = route;

            Regex timeparse = new Regex("([0-9]+):([0-9]+)");

            XmlNode depart     = head.SelectSingleNode("/Flight/depart");
            XmlNode arrive     = head.SelectSingleNode("/Flight/arrive");
            XmlNode daysflying = head.SelectSingleNode("/Flight/operation");

            Match departMatch = timeparse.Match(depart.InnerText);

            if (departMatch.Success)
            {
                this.departure = new FlightTime(Convert.ToInt16(departMatch.Groups[1].Value), Convert.ToInt16(departMatch.Groups[2].Value), Convert.ToBoolean(depart.Attributes["nextDay"].Value));
            }

            Match arriveMatch = timeparse.Match(arrive.InnerText);

            if (arriveMatch.Success)
            {
                this.arrival = new FlightTime(Convert.ToInt16(arriveMatch.Groups[1].Value), Convert.ToInt16(arriveMatch.Groups[2].Value), Convert.ToBoolean(arrive.Attributes["nextDay"].Value));
            }

            // set default value
            for (int i = 0; i < this.daysFlying.Length; i++)
            {
                this.daysFlying[i] = false;
            }

            if ((daysflying.ChildNodes.Count == 1) && (daysflying.ChildNodes[0].InnerText.ToLower().Equals("alldays")))
            {
                for (int i = 0; i < this.daysFlying.Length; i++)
                {
                    this.daysFlying[i] = true;
                }
            }
            else
            {
                foreach (XmlNode day in daysflying)
                {
                    this.daysFlying[FlightTime.indexForDay(day.InnerText)] = true;
                }
            }
        }
Beispiel #2
0
 public bool hasFlightAtTime(FlightTime time, String day)
 { // returns true if time given is before flight
     if (this.departure.compareFlightTime(time) <= 0)
     {
         if (time.nextDay)
         {
             return(daysFlying[FlightTime.indexForDayByAddingDays(day, 1)]);
         }
         else
         {
             return(daysFlying[FlightTime.indexForDay(day)]);
         }
     }
     else
     {
         return(false);
     }
 }