Class Project3

Object
  extended byProject3
All Implemented Interfaces:
IBM

public class Project3
extends Object
implements IBM

The Project 3 main class.


Field Summary
 
Fields inherited from interface IBM
GOLD, metalName, METALS, PLATINUM, URANIUM
 
Constructor Summary
Project3()
           
 
Method Summary
static int consumers()
          Get the number of consumers.
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 requestToString(int[] req)
          Turn a request for resources into a printable string.
static void setVerbose(boolean onOff)
          Turn debugging output on or off.
static int time()
          Handy procedure for timing.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Project3

public Project3()
Method Detail

consumers

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

Returns:
the number of consumers.

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.

requestToString

public static String requestToString(int[] req)
Turn a request for resources into a printable string.

Parameters:
req - an indication of the amount of each metal desired.
Returns:
a string representation of req in the format
"[ng+np+nu] = total"
where ng, np, nu, and total are integers.

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.

main

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

Parameters:
args - the command-line arguments.