コード例 #1
0
ファイル: Shop.cs プロジェクト: DylanUpchr/SimulationMagasin
 /// <summary>
 /// Open or close counters automatically
 /// </summary>
 private void ManageCheckoutCounters()
 {
     //AutoOpen logic
     //If any customer finding a line
     //And any close counters
     //Either all counters closed or any customershave been waiting longer than MAX_WAIT_TIME
     if (
         Customers.Any(c => c.State == CustomerStates.FindingLine && c.TimeSpentWaiting.TotalSeconds >= MAX_WAIT_TIME) &&
         CheckoutCounters.Any(cc => cc.State == CheckoutCounterStates.Closed) &&
         (CheckoutCounters.All(cc => cc.State == CheckoutCounterStates.Closed) ||
          Customers.Any(c => c.TimeSpentWaiting.TotalSeconds >= MAX_WAIT_TIME))
         )
     {
         CheckoutCounters.Where(cc => cc.State == CheckoutCounterStates.Closed).First().State = CheckoutCounterStates.Open;
     }
     //AutoClose logic
     //If there are not any customers finding a line
     //And any checkout counters open
     //And line empty for NB_SECONDS_BEFORE_COUNTER_CLOSES
     //And no customers going to checkout counter
     if (
         !(Customers.Any(c => c.State == CustomerStates.FindingLine)) &&
         CheckoutCounters.Any(cc => cc.State == CheckoutCounterStates.Open &&
                              cc.TimeSinceLineEmpty >= NB_SECONDS_BEFORE_COUNTER_CLOSES &&
                              !Customers.Any(c => c.CheckoutCounter == cc))
         )
     {
         CheckoutCounters.Where(cc => cc.State == CheckoutCounterStates.Open && cc.TimeSinceLineEmpty >= NB_SECONDS_BEFORE_COUNTER_CLOSES).First().State = CheckoutCounterStates.Closed;
     }
 }
コード例 #2
0
ファイル: Shop.cs プロジェクト: DylanUpchr/SimulationMagasin
 /// <summary>
 /// Finds checkout counter with shortest line
 /// </summary>
 /// <returns>Checkout counter</returns>
 public CheckoutCounter GetCheckoutCounterWithShortestLine()
 {
     if (CheckoutCounters.Any(cc => cc.State == CheckoutCounterStates.Open && cc.LineLength < NB_CUSTOMERS_PER_COUNTER))
     {
         return(this.CheckoutCounters.Where(cc => cc.State == CheckoutCounterStates.Open && cc.LineLength < NB_CUSTOMERS_PER_COUNTER).OrderBy(cc => cc.HighestWaitTime).First());
     }
     else
     {
         return(null);
     }
 }