cmsc433.p2
Class Cook
java.lang.Object
cmsc433.p2.Cook
- All Implemented Interfaces:
- java.lang.Runnable
public class Cook
- extends java.lang.Object
- implements java.lang.Runnable
Cooks are simulation actors that have at least one field, a name.
When running, a cook attempts to retrieve outstanding orders placed
by Eaters and process them.
|
Constructor Summary |
Cook(java.lang.String name)
You can feel free modify this constructor. |
|
Method Summary |
void |
run()
This method executes as follows. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Cook
public Cook(java.lang.String name)
- You can feel free modify this constructor. It must
take at least the name, but may take other parameters
if you would find adding them useful.
- Parameters:
name - - the name of the cook
toString
public java.lang.String toString()
- Overrides:
toString in class java.lang.Object
run
public void run()
- This method executes as follows. The cook tries to retrieve
orders placed by Eaters. For each order, a List, the
cook submits each Food item in the List to an appropriate
Machine, by calling makeFood(). Once all machines have
produced the desired Food, the order is complete, and the Eater
is notified. The cook can then go to process the next order.
If during its execution the cook is interrupted (i.e., some
other thread calls the interrupt() method on it, which could
raise InterruptedException if the cook is blocking), then it
terminates.
- Specified by:
run in interface java.lang.Runnable