Class | Tree | Deprecated | Index | Help
PREV | NEXT SHOW LISTS | HIDE LISTS

Interface Calculator.Calculator

Implementing Classes:
CalculatorGUI

public interface Calculator
This is the interface for a basic four-function calculator, as seen from the perspective of its logic. This interface defines an enumerated type, buttonIDs (including 0...9, which represent themselves), an array of ButtonLabels suitable for displaying on the GUI, and the three access functions by which the logic can manipulate the Calculator: getButton, getText, and setText.

See Also:
CalculatorGUI

Field Summary
static java.lang.String[]  ButtonLabels
An array for the button's labels to deal with dispatch cleanly.
static int  CLEAR
Calculator clear button.
static int  DOT
Calculator decimal point.
static int  EQUALS
Calculator = button.
static int  LAST
One more than the biggest button index.
static int  NO_OP
No operation in progress.
static int  OP_ADD
Calculator addition.
static int  OP_DIV
Calculator division.
static int  OP_MUL
Calculator multiplication.
static int  OP_SUB
Calculator subtraction.
 

Method Summary
int  getButton()
Get the next Button pressed.
java.lang.String  getButtonLabel(int buttonID)
Get the label for the given Button ID.
java.lang.String  getText()
Get the text currently displayed on the Calculator.
void  setText(java.lang.String newText)
Set the text currently displayed on the Calculator.
 

Field Detail

NO_OP

public static final int NO_OP
No operation in progress.

OP_DIV

public static final int OP_DIV
Calculator division.

OP_MUL

public static final int OP_MUL
Calculator multiplication.

OP_ADD

public static final int OP_ADD
Calculator addition.

OP_SUB

public static final int OP_SUB
Calculator subtraction.

DOT

public static final int DOT
Calculator decimal point.

EQUALS

public static final int EQUALS
Calculator = button.

CLEAR

public static final int CLEAR
Calculator clear button.

LAST

public static final int LAST
One more than the biggest button index.

ButtonLabels

public static final java.lang.String[] ButtonLabels
An array for the button's labels to deal with dispatch cleanly. You can use this to get the name of the button (i.e., a String).
Method Detail

getButton

public int getButton()
Get the next Button pressed. The return value will be an int between 0 and 9 (if the button was a number) or one of the Calculator constants.
Returns:
the next button to be handled.

getButtonLabel

public java.lang.String getButtonLabel(int buttonID)
Get the label for the given Button ID. The argument should be an int between 0 and 9 (if the button was a number) or one of the Calculator constants, otherwise the empty string ("") will be returned.
Returns:
the button label as a String.

getText

public java.lang.String getText()
Get the text currently displayed on the Calculator.
Returns:
the text as a String.

setText

public void setText(java.lang.String newText)
Set the text currently displayed on the Calculator.
Parameters:
newText - the text to be displayed.

Class | Tree | Deprecated | Index | Help
PREV | NEXT SHOW LISTS | HIDE LISTS