cmsc433.p2
Class Machine
java.lang.Object
cmsc433.p2.Machine
public class Machine
- extends java.lang.Object
A Machine is used to make a particular Food. Each Machine makes
just one kind of Food. Each machine has a capacity: it can make
that many food items in parallel; if the machine is asked to
produce a food item beyond its capacity, the requester blocks.
Each food item takes at least item.cookTimeMS milliseconds to
produce.
|
Constructor Summary |
Machine(java.lang.String name,
Food food,
int capacity)
The constructor takes at least the name of the machine,
the Food item it makes, and its capacity. |
|
Method Summary |
void |
makeFood()
This method is called by a Cook in order to make the Machine's
food item. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
name
public final java.lang.String name
food
public final Food food
Machine
public Machine(java.lang.String name,
Food food,
int capacity)
- The constructor takes at least the name of the machine,
the Food item it makes, and its capacity. You may extend
it with other arguments, if you wish. Notice that the
constructor currently does nothing with the capacity; you
must add code to make use of this field (and do whatever
initialization etc. you need).
makeFood
public void makeFood()
throws java.lang.InterruptedException
- This method is called by a Cook in order to make the Machine's
food item. You can extend this method however you like, e.g.,
you can have it take extra parameters or return something other
than void. It should block if the machine is currently at full
capacity. If not, the method should return, so the Cook making
the call can proceed. You will need to implement some means to
notify the calling Cook when the food item is finished.
- Throws:
java.lang.InterruptedException
toString
public java.lang.String toString()
- Overrides:
toString in class java.lang.Object