acm.io
Interface IOModel

All Known Implementing Classes:
CommandLineProgram, ConsoleProgram, DialogProgram, GraphicsProgram, IOConsole, IODialog, Program

public interface IOModel

The IOModel interface defines the input and output methods supported by both the IOConsole and IODialog classes.


Method Summary
 void print(boolean x)
          Makes sure that print can display a boolean.
 void print(char x)
          Makes sure that print can display a char.
 void print(double x)
          Makes sure that print can display a double.
 void print(float x)
          Makes sure that print can display a float.
 void print(int x)
          Makes sure that print can display an int.
 void print(long x)
          Makes sure that print can display a long.
 void print(Object x)
          Makes sure that print can display an Object.
 void print(String value)
          Displays the argument value, allowing for the possibility of more output on the same line.
 void println()
          Completes the output line.
 void println(boolean x)
          Makes sure that println can display a boolean.
 void println(char x)
          Makes sure that println can display a char.
 void println(double x)
          Makes sure that println can display a double.
 void println(float x)
          Makes sure that println can display a float.
 void println(int x)
          Makes sure that println can display an int.
 void println(long x)
          Makes sure that println can display a long.
 void println(Object x)
          Makes sure that println can display an Object.
 void println(String value)
          Displays the value and then completes the line.
 boolean readBoolean()
          Reads and returns a boolean value from the user, which must match either true or false, ignoring case.
 boolean readBoolean(String prompt)
          Prompts the user to enter a boolean value, which is then returned as the value of this method.
 boolean readBoolean(String prompt, String trueLabel, String falseLabel)
          Prompts the user to enter a value, which is interpreted as a boolean value by matching it against the trueLabel and falseLabel parameters.
 double readDouble()
          Reads and returns a double-precision value from the user.
 double readDouble(double low, double high)
          Reads and returns a double-precision value from the user, which is constrained to be within the specified inclusive range.
 double readDouble(String prompt)
          Prompts the user to enter an double-precision number, which is then returned as the value of this method.
 double readDouble(String prompt, double low, double high)
          Prompts the user to enter an double-precision number, which is then returned as the value of this method.
 int readInt()
          Reads and returns an integer value from the user.
 int readInt(int low, int high)
          Reads and returns an integer value from the user, which is constrained to be within the specified inclusive range.
 int readInt(String prompt)
          Prompts the user to enter an integer, which is then returned as the value of this method.
 int readInt(String prompt, int low, int high)
          Prompts the user to enter an integer, which is then returned as the value of this method.
 String readLine()
          Reads and returns a line of input, without including the end-of-line characters that terminate the input.
 String readLine(String prompt)
          Prompts the user to enter a line of text, which is then returned as the value of this method.
 void showErrorMessage(String msg)
          Displays the error message.
 

Method Detail

print

void print(boolean x)
Makes sure that print can display a boolean.


print

void print(char x)
Makes sure that print can display a char.


print

void print(double x)
Makes sure that print can display a double.


print

void print(float x)
Makes sure that print can display a float.


print

void print(int x)
Makes sure that print can display an int.


print

void print(long x)
Makes sure that print can display a long.


print

void print(Object x)
Makes sure that print can display an Object.


print

void print(String value)
Displays the argument value, allowing for the possibility of more output on the same line. The print method is overloaded so that value can be of any type.

Parameters:
value - The value to be displayed

println

void println()
Completes the output line.


println

void println(boolean x)
Makes sure that println can display a boolean.


println

void println(char x)
Makes sure that println can display a char.


println

void println(double x)
Makes sure that println can display a double.


println

void println(float x)
Makes sure that println can display a float.


println

void println(int x)
Makes sure that println can display an int.


println

void println(long x)
Makes sure that println can display a long.


println

void println(Object x)
Makes sure that println can display an Object.


println

void println(String value)
Displays the value and then completes the line. The println method is overloaded so that value can be of any type.

Parameters:
value - The value to be displayed

readBoolean

boolean readBoolean()
Reads and returns a boolean value from the user, which must match either true or false, ignoring case.

Returns:
The value of the input interpreted as a boolean value

readBoolean

boolean readBoolean(String prompt)
Prompts the user to enter a boolean value, which is then returned as the value of this method.

Parameters:
prompt - The prompt string to display to the user
Returns:
The value of the input interpreted as a boolean value

readBoolean

boolean readBoolean(String prompt,
                    String trueLabel,
                    String falseLabel)
Prompts the user to enter a value, which is interpreted as a boolean value by matching it against the trueLabel and falseLabel parameters.

Parameters:
prompt - The prompt string to display to the user
trueLabel - The string used to indicate true
falseLabel - The string used to indicate false
Returns:
The value of the input interpreted as a boolean value

readDouble

double readDouble()
Reads and returns a double-precision value from the user.

Returns:
The value of the input interpreted as a double

readDouble

double readDouble(double low,
                  double high)
Reads and returns a double-precision value from the user, which is constrained to be within the specified inclusive range.

Parameters:
low - The lowest value in the permitted range
high - The highest value in the permitted range
Returns:
The value of the input interpreted as a double

readDouble

double readDouble(String prompt)
Prompts the user to enter an double-precision number, which is then returned as the value of this method.

Parameters:
prompt - The prompt string to display to the user
Returns:
The value of the input interpreted as a double

readDouble

double readDouble(String prompt,
                  double low,
                  double high)
Prompts the user to enter an double-precision number, which is then returned as the value of this method. The value must be within the inclusive range between low and high.

Parameters:
prompt - The prompt string to display to the user
low - The lowest value in the permitted range
high - The highest value in the permitted range
Returns:
The value of the input interpreted as a double

readInt

int readInt()
Reads and returns an integer value from the user.

Returns:
The value of the input interpreted as a decimal integer

readInt

int readInt(int low,
            int high)
Reads and returns an integer value from the user, which is constrained to be within the specified inclusive range.

Parameters:
low - The lowest value in the permitted range
high - The highest value in the permitted range
Returns:
The value of the input interpreted as a decimal integer

readInt

int readInt(String prompt)
Prompts the user to enter an integer, which is then returned as the value of this method.

Parameters:
prompt - The prompt string to display to the user
Returns:
The value of the input interpreted as a decimal integer

readInt

int readInt(String prompt,
            int low,
            int high)
Prompts the user to enter an integer, which is then returned as the value of this method. The value must be within the inclusive range between low and high.

Parameters:
prompt - The prompt string to display to the user
low - The lowest value in the permitted range
high - The highest value in the permitted range
Returns:
The value of the input interpreted as a decimal integer

readLine

String readLine()
Reads and returns a line of input, without including the end-of-line characters that terminate the input.

Returns:
The next line of input as a String

readLine

String readLine(String prompt)
Prompts the user to enter a line of text, which is then returned as the value of this method. The end-of-line characters that terminate the input are not included in the returned string.

Parameters:
prompt - The prompt string to display to the user
Returns:
The next line of input as a String

showErrorMessage

void showErrorMessage(String msg)
Displays the error message.

Parameters:
msg - The error msg to be displayed