|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectUtil139
public class Util139
This class implements some functions needed in cs139.
Method Summary | |
---|---|
static java.lang.String |
getProgLoc()
This function returns a string indicating the file, method, and line number of where this method was called. |
static java.lang.String |
getProgLoc(int levelAdjust)
This function returns a string indicating the file, method, and line number of the place adjustLevel method calls
prior to where this method was called. |
static int |
nextRandomInt(int range)
This function returns a random integer in the range 0 to range -1. |
static void |
printDebug(boolean doDebug,
java.lang.String format,
java.lang.Object... args)
This function outputs a debugging message if doDebug
is true. |
static void |
printDebug(int stmtDebugLevel,
java.lang.String format,
java.lang.Object... args)
This function outputs a debugging message if the program's debug is greater than or equal to stsmtDebugLevel . |
static double |
readDouble(java.util.Scanner stream,
java.lang.String prompt)
This function outputs a prompt to standard output, reads the next line of input from stream , outputs
a newline character, and then returns the double value
on the line (any input on the line after the double value
is ignored). |
static int |
readInt(java.util.Scanner stream,
java.lang.String prompt)
This function outputs a prompt to standard output, reads the next line of input from stream , outputs
a newline character, and then returns the int value
on the line (any input on the line after the int value
is ignored). |
static java.lang.String |
readString(java.util.Scanner stream,
java.lang.String prompt)
This function outputs a prompt to standard output, reads the next line of input from stream , outputs
a newline character, and then returns the String value
on the line (any input on the line after the String value
is ignored). |
static boolean |
readYesNo(java.util.Scanner stream,
java.lang.String prompt)
Method purpose: this function prompts the user for a yes or no input and returns true if the user responds affirmatively, and return false if the user responds negatively. |
static void |
setProgDebugLevel(int level)
This function sets the program's debug level as used by printDebug |
static void |
setRandomSeed(long seed)
This function sets the seed for the random number generator implemented in this class. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void setRandomSeed(long seed)
public static int nextRandomInt(int range)
range
-1.
range
- Specifies the range of the random number.
range
-1.public static int readInt(java.util.Scanner stream, java.lang.String prompt)
stream
, outputs
a newline character, and then returns the int value
on the line (any input on the line after the int value
is ignored).
stream
- A Scanner
object input is read fromprompt
- The prompt string.
public static double readDouble(java.util.Scanner stream, java.lang.String prompt)
stream
, outputs
a newline character, and then returns the double value
on the line (any input on the line after the double value
is ignored).
stream
- A Scanner
object input is read fromprompt
- The prompt string.
public static java.lang.String readString(java.util.Scanner stream, java.lang.String prompt)
stream
, outputs
a newline character, and then returns the String value
on the line (any input on the line after the String value
is ignored).
stream
- A Scanner
object input is read fromprompt
- The prompt string.
public static boolean readYesNo(java.util.Scanner stream, java.lang.String prompt)
stream
- Input stream the input is to be read from.prompt
- The prompt output before trying to read.
public static void setProgDebugLevel(int level)
level
- Value the program's debug level gets set topublic static void printDebug(boolean doDebug, java.lang.String format, java.lang.Object... args)
doDebug
is true.
The debugging message indicates the location in the program where
this method was called, following by the output generated
from the "printf" format string and the arguments that following
it. If the format string is just "\n", just the program
location is printed.
doDebug
- Boolean indicating whether or not to print the debug statementsformat
- The printf style format stringargs
- The arguments used by the format stringpublic static void printDebug(int stmtDebugLevel, java.lang.String format, java.lang.Object... args)
stsmtDebugLevel
.
The debugging message indicate the location in the program where
this method was called, following by the output generated
from the "printf" format string and the arguments that following
it. If the format string is just "\n", just the program
location is printed.
stmtDebugLevel
- The debugging of level of this print statementformat
- The printf style format stringargs
- The arguments used by the format stringpublic static java.lang.String getProgLoc(int levelAdjust)
adjustLevel
method calls
prior to where this method was called.
levelAdjust
- An integer indicating how far up the stack to find the location
public static java.lang.String getProgLoc()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |