private void leaveRestaurant() {
    check = null;
    log("I'm leaving! Goodbye!");
    customerGui.DoExitRestaurant();

    person.setGuiVisible();
    person.setRoleInactive(this);
  }
  private void readyToOrder() {
    customerGui.clearOrder();

    timer.schedule(
        new TimerTask() {
          public void run() {
            log("I'm ready to order!");
            callWaiter();
          }
        },
        3000);
  }
  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;
      }
    }
  }
  private void payBill() {
    waiter.msgImFinished(this);

    customerGui.DoGoToCashier();

    try {
      atDestination.acquire();
    } catch (InterruptedException e) {
      e.printStackTrace();
    }

    if (money > check.amount) {
      log("Here is my payment of $" + money + ".");
      check.cashier.msgPayBill(check, money);
      money = 0.0;
    } else {
      check.cashier.msgPayBill(check, money);
      log("This is all I have. Take $" + money + ".");
      money = 0;
    }
  }
 private void eatFood() {
   log("Eating Food");
   customerGui.startedEating(choice);
   // This next complicated line creates and starts a timer thread.
   // We schedule a deadline of getHungerLevel()*1000 milliseconds.
   // When that time elapses, it will call back to the run routine
   // located in the anonymous class created right there inline:
   // TimerTask is an interface that we implement right there inline.
   // Since Java does not all us to pass functions, only objects.
   // So, we use Java syntactic mechanism to create an
   // anonymous inner class that has the public method run() in it.
   timer.schedule(
       new TimerTask() {
         public void run() {
           log("Done eating!");
           event = AgentEvent.doneEating;
           GuiDoneEating();
           // isHungry = false;
           person.stateChanged();
         }
       },
       hungerLevel * 1000); // how long to wait before running task
 }
 public void setGuiActive() {
   customerGui.setPresent(true);
   customerGui.setHungry();
 }
 private void impatientLeaveRestaurant() {
   log("I'm leaving! Goodbye!");
   host.msgImLeaving(this);
   customerGui.DoExitRestaurant();
 }
 private void GuiDoneEating() {
   customerGui.doneEating();
 }
 private void callWaiter() {
   waiter.msgImReadyToOrder(this);
   customerGui.wantToOrder();
 }
 private void sitDown() {
   log("Being seated. Going to table");
   customerGui.DoGoToSeat();
 }
 private void goToWaitingSpot() {
   customerGui.DoGoToSpot(waitingSpot);
   goingInside = false;
 }