Class Brewer

Object
  extended by Brewer
All Implemented Interfaces:
Runnable

public class Brewer
extends Object
implements Runnable

A consumer of grain.
CS 537, Spring 2007, Project 3.


Field Summary
private  Order consumed
          Total consumed thus far.
private  int id
          Id of this Brewer.
private  Order maxRequest
          Maximum amount of each grain to ask for on each request.
private  int meanSleepTime
          Mean sleep time (in milliseconds) between purchase requests.
private  int numberOfRequests
          Number of requests completed so far.
private  int totalServiceTime
          Sum of service times for all requests.
private static int VERSION
          Source version number.
 
Constructor Summary
Brewer(int id)
          Creates a new Brewer object.
 
Method Summary
private  void consume(Order amount)
          Consumes the indicated amounts of resources.
 Order getConsumption()
          Reports on the total amount consumed thus far.
 int requestsCompleted()
          Returns the number of requests to the Warehouse successfully completed by this Brewer.
 void run()
          Main loop.
 int waitingTime()
          Returns the time in milliseconds this Brewer has spent waiting.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION

private static final int VERSION
Source version number.

See Also:
Constant Field Values

id

private int id
Id of this Brewer.


meanSleepTime

private int meanSleepTime
Mean sleep time (in milliseconds) between purchase requests.


maxRequest

private Order maxRequest
Maximum amount of each grain to ask for on each request.


consumed

private Order consumed
Total consumed thus far.


numberOfRequests

private int numberOfRequests
Number of requests completed so far.


totalServiceTime

private int totalServiceTime
Sum of service times for all requests.

Constructor Detail

Brewer

public Brewer(int id)
Creates a new Brewer object.

Parameters:
id - the unique id of this brewer.
Method Detail

getConsumption

public Order getConsumption()
Reports on the total amount consumed thus far.

Returns:
the amount consumed thus far.

requestsCompleted

public int requestsCompleted()
Returns the number of requests to the Warehouse successfully completed by this Brewer.

Returns:
number of successful requests

waitingTime

public int waitingTime()
Returns the time in milliseconds this Brewer has spent waiting.

Returns:
the waiting time

consume

private void consume(Order amount)
Consumes the indicated amounts of resources.

Parameters:
amount - a vector of amounts, one for each grain.

run

public void run()
Main loop. Repeatedly generates random requests to the warehouse.

Specified by:
run in interface Runnable