/** Scheduler. Determine what action is called for, and do it. */
  public boolean pickAndExecuteAnAction() {
    /* Think of this next rule as:
             Does there exist a table and customer,
             so that table is unoccupied and customer is waiting.
             If so seat him at the table.
    */

    if (Orders != null) {
      synchronized (Orders) {
        for (int i = 0; i < Orders.size(); i++) {
          if (Orders.get(i).s == OrderState.done) {
            DeliverOrder(Orders.get(i));
            return true;
          } else if (Orders.get(i).s == OrderState.pending) {
            TryRestockOrder(Orders.get(i));
            return true;
          }
        }
      }
    }

    return false;
    // we have tried all our rules and found
    // nothing to do. So return false to main loop of abstract agent
    // and wait.
  }
 public void msgHereIsPayment(ItalianCashier cashier, Double payment) {
   synchronized (Orders) {
     for (int i = 0; i < Orders.size(); i++) {
       if (Orders.get(i).food.orderamt * Orders.get(i).food.price == payment) {
         print("Received payment of " + payment + " from " + cashier);
         Orders.remove(Orders.get(i));
         stateChanged();
       }
     }
   }
 }
 // message from waiter to market to fulfill inventory
 public void msgOrderforMarket(ItalianCook c, String choice, int amount) {
   int foodamount;
   synchronized (Foods) {
     for (int i = 0; i < Foods.size(); i++) {
       if (Foods.get(i).type.equals(choice)) {
         if (Foods.get(i).inventory - amount > 0) {
           foodamount = amount;
         } else {
           foodamount = Foods.get(i).inventory;
         }
         Orders.add(new Order(c, Foods.get(i), foodamount, Foods.get(i).inventory - foodamount));
         print("Filling order from " + c + " for " + foodamount + " more " + Foods.get(i));
         stateChanged();
       }
     }
   }
   /*
   for(int i=0; i<Orders.size();i++){
   	if(Orders.get(i).s == OrderState.pending)
   		TryRestockOrder(Orders.get(i));
   }*/
 }