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(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(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

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.

 
Usage: model.print(value); 
Parameter: 
value  The value to be displayed
 


void println()

Completes the output line.

 
Usage: io.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.

 
Usage: io.println(value); 
Parameter: 
value  The value to be displayed
 


boolean readBoolean()

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

 
Usage: boolean flag = io.readBoolean(); 
Returns: The value of the input interpreted as a boolean value
 


boolean readBoolean(String prompt)

Prompts the user to enter a boolean value, which is then returned as the value of this method.

 
Usage: boolean flag = io.readBoolean(prompt); 
Parameter: 
prompt  The prompt string to display to the user
Returns: The value of the input interpreted as a boolean value
 


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.

 
Usage: boolean flag = dialog.readBoolean(prompt); 
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
 


double readDouble()

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

 
Usage: double d = io.readDouble(); 
Returns: The value of the input interpreted as a double
 


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.

 
Usage: double d = io.readDouble(low, high); 
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
 


double readDouble(String prompt)

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

 
Usage: double d = io.readDouble(prompt); 
Parameter: 
prompt  The prompt string to display to the user
Returns: The value of the input interpreted as a double
 


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.

 
Usage: d = io.readDouble(prompt, low, 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
 


int readInt()

Reads and returns an integer value from the user.

 
Usage: int n = io.readInt(); 
Returns: The value of the input interpreted as a decimal integer
 


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.

 
Usage: int n = io.readInt(low, high); 
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
 


int readInt(String prompt)

Prompts the user to enter an integer, which is then returned as the value of this method.

 
Usage: int n = io.readInt(prompt); 
Parameter: 
prompt  The prompt string to display to the user
Returns: The value of the input interpreted as a decimal integer
 


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.

 
Usage: int n = io.readInt(prompt, low, 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
 


String readLine()

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

 
Usage: String str = io.readLine(); 
Returns: The next line of input as a String
 


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.

 
Usage: String str = io.readLine(prompt); 
Parameter: 
prompt  The prompt string to display to the user
Returns: The next line of input as a String
 


void showErrorMessage(String msg)

Displays the error message.

 
Usage: io.showErrorMessage(msg); 
Parameter: 
msg  The error msg to be displayed