private void LeaveRestaurant() { Do("Leaving."); customerGui.setText(""); customerGui.DoExitRestaurant(); }
/** Scheduler. Determine what action is called for, and do it. */ protected boolean pickAndExecuteAnAction() { // CustomerAgent is a finite state machine try { if (state == AgentState.DoingNothing && event == AgentEvent.gotHungry) { if (host.isFull() && name.equalsIgnoreCase("wait")) { customerGui.setEnabled(); customerGui.DoExitRestaurant(); return true; } state = AgentState.Waiting; GoToRestaurant(); return true; } if (state == AgentState.Waiting && event == AgentEvent.followHost) { state = AgentState.BeingSeated; SitDown(); return true; } if (state == AgentState.BeingSeated && event == AgentEvent.seated) { state = AgentState.Seated; return true; } if (state == AgentState.Seated && event == AgentEvent.orderFood) { state = AgentState.Ordered; OrderFood(); return true; } if (state == AgentState.Ordered && event == AgentEvent.orderTaken) { state = AgentState.WaitingForOrder; return true; } if (state == AgentState.WaitingForOrder && event == AgentEvent.foodArrived) { state = AgentState.Eating; EatFood(); return true; } if (state == AgentState.Eating && event == AgentEvent.doneEating) { state = AgentState.WaitingForCheck; customerGui.setText(""); waiter.msgDoneEating(this); return true; } if (state == AgentState.WaitingForCheck && event == AgentEvent.rcvdCheck) { state = AgentState.Paying; LeaveTableToGoPay(); return true; } if (state == AgentState.Paying && event == AgentEvent.arrivedAtCashier) { host.cashier.msgHereIsMoney(this, wallet.getAmt()); return true; } if (state == AgentState.Paying && event == AgentEvent.doDishes) { DoDishes(); return true; } if (state == AgentState.Paying && event == AgentEvent.donePaying) { state = AgentState.Leaving; eatingSuccess = true; LeaveRestaurant(); return true; } if (state == AgentState.Leaving && event == AgentEvent.doneLeaving) { state = AgentState.DoingNothing; // person.msgDoneEating(eatingSuccess, wallet.getAmt()); // COMMENT THIS OUT IF THERE // AREN'T REAL PEOPLE IN THE RESTAURANT waiter.msgDoneLeaving(this); return true; } return false; } catch (ConcurrentModificationException e) { return false; } }