dbrown
Class Chef

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

 class Chef
extends java.lang.Object
implements java.lang.Runnable

Represents a chef in a restaurant who prepares orders until the restaurant closes. After finishing an order the chef notifies the waiter that the order is ready.

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

Field Summary
static int COOKING
           
static int DONE
           
static int FREE
           
private  Order order
           
private  Restaurant restaurant
           
private  int status
           
private  java.lang.Thread t
          The chef's execution thread.
private  java.util.ArrayList<IView> views
           
 
Constructor Summary
Chef(Restaurant r)
          The chef constructor
 
Method Summary
 void addView(IView newView)
          Adds a view to the model's collection of views.
 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

COOKING

public static final int COOKING
See Also:
Constant Field Values

DONE

public static final int DONE
See Also:
Constant Field Values

FREE

public static final int FREE
See Also:
Constant Field Values

order

private Order order

restaurant

private Restaurant restaurant

status

private int status

t

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


views

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

Chef

public Chef(Restaurant r)
The chef constructor

Parameters:
r - The restaurant the chef works in.
Method Detail

addView

public void addView(IView newView)
Adds a view to the model's collection of views.

Parameters:
newView - The view to add to the model's collection of views.

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.