Class Supplier

java.lang.Object
  |
  +--Supplier
All Implemented Interfaces:
Enron, Runnable

public class Supplier
extends Object
implements Runnable, Enron

CS 537, Fall 2002, Project 3. A supplier of energy resources.

Copyright © 2002 by Marvin Solomon. All rights reserved.


Field Summary
private  int iterations
          Number of times to iterate before terminating.
private  int[] maxSupply
          Maximum amount of each commodity to supply on each iteration.
private  int meanSleepTime
          Mean time to sleep between iterations (in milliseconds).
private  Random rand
          Source of random numbers.
private  int[] supplied
          Amount supplied.
private  Trader trader
          The trader to supply.
 
Fields inherited from interface Enron
cname, COAL, COMMODITIES, cunit, ELEC, GAS, OIL
 
Constructor Summary
Supplier(Trader trader, int iterations)
          Creates a new supplier.
 
Method Summary
private static void pl(Object o)
          Abbreviation for System.out.println.
 void run()
          Main loop.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

trader

private Trader trader
The trader to supply.


iterations

private int iterations
Number of times to iterate before terminating.


meanSleepTime

private int meanSleepTime
Mean time to sleep between iterations (in milliseconds).


maxSupply

private int[] maxSupply
Maximum amount of each commodity to supply on each iteration.


rand

private Random rand
Source of random numbers.


supplied

private int[] supplied
Amount supplied.

Constructor Detail

Supplier

public Supplier(Trader trader,
                int iterations)
Creates a new supplier.

Parameters:
trader - the trader to supply.
Method Detail

run

public void run()
Main loop. Repeatedly supply one unit of each resource to the trader. After iterations iterations, tell the trader to shut down.

Specified by:
run in interface Runnable

pl

private static void pl(Object o)
Abbreviation for System.out.println.

Parameters:
o - the object to be printed.