All Packages Class Hierarchy This Package Previous Next Index
Interface Calculator.Calculator
- 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
-
ButtonLabels
- An array for the button's labels to deal with dispatch cleanly.
-
CLEAR
- Calculator clear button.
-
DOT
- Calculator decimal point.
-
EQUALS
- Calculator = button.
-
LAST
- One more than the biggest button index.
-
NO_OP
- No operation in progress.
-
OP_ADD
- Calculator addition.
-
OP_DIV
- Calculator division.
-
OP_MUL
- Calculator multiplication.
-
OP_SUB
- Calculator subtraction.
-
getButton()
- Get the next Button pressed.
-
getText()
- Get the text currently displayed on the Calculator.
-
setText(String)
- Set the text currently displayed on the Calculator.
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 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).
getButton
public abstract 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.
getText
public abstract String getText()
- Get the text currently displayed on the Calculator.
- Returns:
- the text as a String.
setText
public abstract void setText(String newText)
- Set the text currently displayed on the Calculator.
- Parameters:
- newText - the text to be displayed.
All Packages Class Hierarchy This Package Previous Next Index