Пример #1
0
  private void orderFood() {
    if (menu.getChoice(choice).price < money) {
      log("I would like an order of " + choice + " please!");

      customerGui.orderedFood(choice);
      log(choice + " please!");

      waiter.msgHereIsMyChoice(this, choice);
    } else {
      for (int i = 0; i < menu.getMenuSize(); i++) { // Try to find a choice the customer can afford
        if (menu.getChoice(i).price < money) {
          choice = menu.getChoice(i).type;

          log("I would like an order of " + choice + " please!");

          customerGui.orderedFood(choice);
          log(choice + " please!");

          waiter.msgHereIsMyChoice(this, choice);
          return;
        }
      }
      if (name.equals("flake")) { // This customer will buy food he/she can't afford
        log("I would like an order of " + choice + " please!");

        customerGui.orderedFood(choice);
        log(choice + " please!");

        waiter.msgHereIsMyChoice(this, choice);
      } else {
        log("Everything is too expensive, I'm going to leave.");

        customerGui.doneEating();
        waiter.msgImFinished(this);
        event = AgentEvent.leaving;
      }
    }
  }
Пример #2
0
 public void msgRemoveFromMenu(String choice) {
   menu.removeChoice(choice);
 }