Class P2

Object
  extended by P2

public class P2
extends Object

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


Constructor Summary
P2()
           
 
Method Summary
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 void main(String[] args)
          Main program for project 2.
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 Trader specialist(Grain g)
          Returns the specialist for a given grain.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

P2

public P2()
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.

specialist

public static Trader specialist(Grain g)
Returns the specialist for a given grain.

Parameters:
g - the grain.
Returns:
the Trader that specializes in grain g.

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

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.

main

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

Parameters:
args - the command-line arguments.