Class Resource

java.lang.Object
  extended by Resource

public class Resource
extends Object

Resource class -- manages agents requesting a resource

Author:
Mark Guzdial, Barb Ericson

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()
          Method to get the 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
 

Constructor Detail

Resource

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

Method Detail

amountAvailable

public int amountAvailable()
Method to get the amount available

Returns:
the amount

consume

public void consume(int amtDesired)
Consume resource

Parameters:
amtDesired - the amount desired

add

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

Parameters:
production - the amount produced

addToList

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

Parameters:
agent - the agent to add as waiting