dbrown
Class Waiter

java.lang.Object
  extended by dbrown.Waiter
All Implemented Interfaces:
java.lang.Runnable

public class Waiter
extends java.lang.Object
implements java.lang.Runnable

Simluates a simple waiter who can handle a single order at a time, and waits until an order is available before doing anything.

Version:
2004-11-09
Author:
David B. Brown from Bruce Eckel

Field Summary
static int DONE
          Comment for DONE
static int FREE
          Comment for FREE
private  Order order
           
private  Restaurant restaurant
           
static int SERVING
          Comment for SERVING
private  int status
           
private  java.lang.Thread t
          The waiter's execution thread.
private  java.util.ArrayList<IView> views
           
 
Constructor Summary
Waiter(Restaurant r)
          The Waiter constructor.
 
Method Summary
 void addView(IView newView)
           
 Order getOrder()
           
 int getStatus()
           
 void run()
           
 void setOrder(Order order)
           
 void setStatus(int status)
           
private  void updateViews()
          Updates all views attached to the model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DONE

public static final int DONE
Comment for DONE

See Also:
Constant Field Values

FREE

public static final int FREE
Comment for FREE

See Also:
Constant Field Values

SERVING

public static final int SERVING
Comment for SERVING

See Also:
Constant Field Values

order

private Order order

restaurant

private Restaurant restaurant

status

private int status

t

private java.lang.Thread t
The waiter's execution thread.


views

private java.util.ArrayList<IView> views
Constructor Detail

Waiter

public Waiter(Restaurant r)
The Waiter constructor.

Parameters:
r - The restaurant the waiter works at.
Method Detail

addView

public void addView(IView newView)
Parameters:
newView -

getOrder

public Order getOrder()
Returns:
Returns the order.

getStatus

public int getStatus()
Returns:
Returns the status.

run

public void run()
Specified by:
run in interface java.lang.Runnable

setOrder

public void setOrder(Order order)
Parameters:
order - The order to set.

setStatus

public void setStatus(int status)
Parameters:
status - The status to set.

updateViews

private void updateViews()
Updates all views attached to the model.