Class P3

Object
  extended by P3

public class P3
extends Object

The Project 3 main class.
CS 537, Spring 2007, Project 3.


Field Summary
private static int brewerCount
          Number of Brewers.
private static Brewer[] brewers
          Brewers.
private static Thread[] brewerThreads
          Brewer threads.
private static Random rand
          Random number generator.
private static long startTime
          Startup time (used to support the time() method.
private static Supplier supplier
          The unique supplier.
private static boolean verbose
          Flag to control debugging output.
private static int VERSION
          Source version number.
private static Warehouse warehouse
          The unique Warehouse.
 
Constructor Summary
P3()
           
 
Method Summary
static int brewers()
          Returns the number of Brewers in the system.
static void debug(Object message)
          If the debugging flag is on, prints a message, preceded by the name of the current thread.
static void debug(String format, Object... args)
          If the debugging flag is on, prints a message, preceded by the name of the current thread.
static int expo(int mean)
          Generates an exponentially distributed random number.
static Warehouse getWarehouse()
          Returns the unique Warehouse instance.
static void main(String[] args)
          Main program for project 3.
static int randInt(int max)
          Utility to generate a random non-negative integer less than max.
static int randInt(int min, int max)
          Utility to generate a random integer between min and max (inclusive).
static void setVerbose(boolean on)
          Turns debugging output on or off.
static int time()
          Handy procedure for timing.
private static void usage()
          Prints a usage message and terminates.
 
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

brewerCount

private static int brewerCount
Number of Brewers.


warehouse

private static Warehouse warehouse
The unique Warehouse.


brewers

private static Brewer[] brewers
Brewers.


brewerThreads

private static Thread[] brewerThreads
Brewer threads.


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.


rand

private static Random rand
Random number generator.

Constructor Detail

P3

public P3()
Method Detail

setVerbose

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

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

getWarehouse

public static Warehouse getWarehouse()
Returns the unique Warehouse instance.

Returns:
the warehouse.

debug

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

Parameters:
message - the message to print.

debug

public static void debug(String format,
                         Object... args)
If the debugging flag is on, prints a message, preceded by the name of the current thread. If it is off, does nothing.

Parameters:
format - a printf-like format for the message
args - arguments to the printf

time

public static int time()
Handy procedure for timing.

Returns:
the elapsed time since startup, in milliseconds.

brewers

public static int brewers()
Returns the number of Brewers in the system.

Returns:
the number of Brewers.

randInt

public static int randInt(int max)
Utility to generate a random non-negative integer less than max.

Parameters:
max - integer one greater than the largest possible result.
Returns:
a non-negative integer strictly less than max.

randInt

public static int randInt(int min,
                          int max)
Utility to generate a random integer between min and max (inclusive).

Parameters:
min - the smallest possible result.
max - the largest possible result.
Returns:
an integer between min and max, inclusive.

expo

public static int expo(int mean)
Generates an exponentially distributed random number.

Parameters:
mean - the mean of the distribution.
Returns:
the next sample value.

usage

private static void usage()
Prints a usage message and terminates.


main

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

Parameters:
args - the command-line arguments.