public void Next()
 {
     if (!station.IsFull)
     {
         if (baggageCount.Count != 0)
         {
             var bags = baggageCount.Where((p, i) => currCount.ElementAt(i).Value <= p.Value);
             if (bags.Count() > 0)
             {
                 KeyValuePair <string, int> pair = bags.ElementAt(rand.Next(bags.Count()));
                 Baggage b = new Baggage(pair.Key, currCount[pair.Key], currColor[pair.Key]);
                 station.AddBag(b);
                 currCount[pair.Key] += 1;
             }
         }
     }
 }
Beispiel #2
0
        private void btPutBaggage_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(tbFlight.Text))
            {
                MessageBox.Show("航班号不能为空!");
                return;
            }
            if (string.IsNullOrEmpty(tbBaggage.Text))
            {
                MessageBox.Show("行李号不能为空!");
                return;
            }
            if (!algo.FlightTime.Keys.Contains(tbFlight.Text))
            {
                MessageBox.Show("航班号不存在,请先配置航班号!");
                return;
            }
            Baggage b = new Baggage(tbFlight.Text, int.Parse(tbBaggage.Text));

            station.AddBag(b);
        }