Class Project3

java.lang.Object
  |
  +--Project3
All Implemented Interfaces:
Enron

public class Project3
extends Object
implements Enron

The Project 3 main class.


Field Summary
private static Thread[] cthread
          Array of Customer threads.
private static Customer[] customer
          Array of Customer instances.
private static int customerCount
          Number of customers (from the command line).
private static long startTime
          Startup time (used to support the time() method.
private static Supplier supplier
          The unique Supplier.
private static Trader trader
          The unique Trader.
private static boolean verbose
          Flag to control debugging output.
 
Fields inherited from interface Enron
cname, COAL, COMMODITIES, cunit, ELEC, GAS, OIL
 
Constructor Summary
Project3()
           
 
Method Summary
static int customers()
          Get the number of customers.
static void debug(Object message)
          Debug print.
static int expo(Random rand, int mean)
          Generate an exponentially distributed random number.
static void main(String[] args)
          Main program for project 3.
static String orderToString(int[] order)
          Turn an order into a printable string.
static void setVerbose(boolean onOff)
          Turn debugging output on or off.
static int time()
          Handy procedure for timing.
private static void usage()
          Print a usage message and terminate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

customer

private static Customer[] customer
Array of Customer instances.


cthread

private static Thread[] cthread
Array of Customer threads.


trader

private static Trader trader
The unique Trader.


supplier

private static Supplier supplier
The unique Supplier.


startTime

private static long startTime
Startup time (used to support the time() method.


verbose

private static boolean verbose
Flag to control debugging output.


customerCount

private static int customerCount
Number of customers (from the command line).

Constructor Detail

Project3

public Project3()
Method Detail

customers

public static int customers()
Get the number of customers.

Returns:
the number of customers.

setVerbose

public static void setVerbose(boolean onOff)
Turn debugging output on or off.

Parameters:
onOff - if true, turn debugging on; otherwise turn it off.

debug

public static void debug(Object message)
Debug print. If the debugging flag is on, print a message, preceded by the name of the current thread. If it is off, do nothing.

Parameters:
message - the message to print.

time

public static int time()
Handy procedure for timing.

Returns:
the elapsed time since startup, in milliseconds.

orderToString

public static String orderToString(int[] order)
Turn an order into a printable string.

Parameters:
order - an indication of the amount of each commodity desired.

expo

public static int expo(Random rand,
                       int mean)
Generate an exponentially distributed random number.

Parameters:
rand - the source of random numbers.
mean - the mean of the distribution.
Returns:
the next sample value.

usage

private static void usage()
Print a usage message and terminate.


main

public static void main(String[] args)
Main program for project 3.

Parameters:
args - the command-line arguments.