示例#1
0
        /// <summary>
        /// Returns a list of pilots of a certain age.
        /// </summary>
        /// <param name="lowerAge">Lower age of pilots who should be returned.</param>
        /// <param name="upperAge">Upper age of pilots who should be returned.</param>
        /// <returns></returns>
        public MyListOfPilots GetPilotsOfAge(int lowerAge, int upperAge)
        {
            MyListOfPilots cityFlights = new MyListOfPilots();

            foreach (Pilot p in pilots)
            {
                if (p.Age >= lowerAge && p.Age <= upperAge)
                {
                    cityFlights.Add(p);
                }
            }
            return(cityFlights);
        }
示例#2
0
        private void btnShowPilotsOfAge_Click(object sender, EventArgs e)
        {
            int            lowerAge    = Convert.ToInt32(tbLowerLimit.Text);
            int            upperAge    = Convert.ToInt32(tbUpperLimit.Text);
            MyListOfPilots cityFlights = airlines.GetPilotsOfAge(lowerAge, upperAge);
            Node           node        = cityFlights.First;

            lbxPilotsOfAge.Items.Clear();
            while (node != null)
            {
                lbxPilotsOfAge.Items.Add(node.Pilot);
                node = node.Next;
            }
        }