コード例 #1
0
 public ItalianMarketRole(String name) {
   super(name);
   Foods.add(new Food("Steak", 11, 15, 15.99)); // name, restocking time, inventory, low, price
   Foods.add(new Food("Chicken", 12, 20, 10.99));
   Foods.add(new Food("Salad", 10, 100, 5.99));
   Foods.add(new Food("Pizza", 13, 100, 8.99));
 }
コード例 #2
0
 // 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));
   }*/
 }