Class Resource

java.lang.Object
  extended byResource
Direct Known Subclasses:
FactoryProduct

public class Resource
extends Object

Resource class -- manages agents requesting a resource


Field Summary
protected  int amount
          Amount of resource available
protected  Queue blocked
          Queue of who's waiting for resource
 
Constructor Summary
Resource()
          Start out with no resource and an empty queue
 
Method Summary
 void add(int production)
          Add more produced resource.
 void addToList(DEAgent agent)
          addToList -- add this agent to this resource's waiting list.
 int amountAvailable()
          Amount available
 void consume(int amtDesired)
          Consume resource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

amount

protected int amount
Amount of resource available


blocked

protected Queue blocked
Queue of who's waiting for resource

Constructor Detail

Resource

public Resource()
Start out with no resource and an empty queue

Method Detail

amountAvailable

public int amountAvailable()
Amount available


consume

public void consume(int amtDesired)
Consume resource


add

public void add(int production)
Add more produced resource. Is there enough to unblock the first Agent in the Queue?


addToList

public void addToList(DEAgent agent)
addToList -- add this agent to this resource's waiting list.