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

    person.setGuiVisible();
    person.setRoleInactive(this);
  }
예제 #2
0
  private void readyToOrder() {
    customerGui.clearOrder();

    timer.schedule(
        new TimerTask() {
          public void run() {
            log("I'm ready to order!");
            callWaiter();
          }
        },
        3000);
  }
예제 #3
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;
      }
    }
  }
예제 #4
0
  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;
    }
  }
예제 #5
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
 }
예제 #6
0
 public void setGuiActive() {
   customerGui.setPresent(true);
   customerGui.setHungry();
 }
예제 #7
0
 private void impatientLeaveRestaurant() {
   log("I'm leaving! Goodbye!");
   host.msgImLeaving(this);
   customerGui.DoExitRestaurant();
 }
예제 #8
0
 private void GuiDoneEating() {
   customerGui.doneEating();
 }
예제 #9
0
 private void callWaiter() {
   waiter.msgImReadyToOrder(this);
   customerGui.wantToOrder();
 }
예제 #10
0
 private void sitDown() {
   log("Being seated. Going to table");
   customerGui.DoGoToSeat();
 }
예제 #11
0
 private void goToWaitingSpot() {
   customerGui.DoGoToSpot(waitingSpot);
   goingInside = false;
 }