public class Utils
extends java.lang.Object
Constructor and Description |
---|
Utils() |
Modifier and Type | Method and Description |
---|---|
static void |
main(java.lang.String[] args)
A test driver main() method for this class.
|
static void |
pause()
The default version, with no indentation, no pause number,
no special message, so only the "Press Enter to continue ...
|
static void |
pause(int indentLevel)
The version in which the "Press Enter to continue ...
|
static void |
pause(int indentLevel,
java.lang.String message)
The version in which the "Press Enter to continue ...
|
static void |
pause(int indentLevel,
java.lang.String message,
int pauseNumber)
Causes the program to pause and wait for the user to press Enter
to continue, with default values for the indentation level, the
message supplying any additional information to the user, and the
pause number.
|
static boolean |
userSaysYes(java.lang.String question)
Gets the user's yes-or-no answer to a single question.
|
public static void pause(int indentLevel, java.lang.String message, int pauseNumber)
indentLevel
- The number of spaces to indent the first line
of each part of the output from the left margin.message
- The message to be displayed, giving the reason for
this particular pause, if such a message is supplied.pauseNumber
- The number of this particular pause, if pauses
are being numbered.
Pre-conditions:
Post-conditions:
This is pause #6.
Press Enter to continue ...has been displayed, with the cursor at the end of the line, positioned one space beyond the ellipsis.
public static void pause(int indentLevel, java.lang.String message)
indentLevel
- The number of spaces to indent the first line
of each part of the output from the left margin.message
- The message to be displayed, giving the reason for
this particular pause, if such a message is supplied.public static void pause(int indentLevel)
indentLevel
- The number of spaces to indent the first line
of each part of the output from the left margin.public static void pause()
public static boolean userSaysYes(java.lang.String question)
question
- Text of the question the user is asked, including the
question mark.Pre-conditions:
Post-conditions:
The text in question has been displayed, followed by (y/[n]) and the user has responded by entering a character and pressing Enter. The value true is returned if the user responds positively to the question asked by entering a y or a Y. Entering any other letter or word, as well as simply pressing the Enter key, will be interpreted as a negative response and the return value will be false. The use of [n] as part of the user prompt is meant to indicate to the user that simply pressing Enter will generate a (default) response of "no". This is a convention of reasonably widespread use in console applications.
public static void main(java.lang.String[] args)
args
- The array of command-line parameters.