Calculator Problem Set Javadocs

calculator
Interface Calculator

All Known 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 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.

See Also:
Constant Field Values

OP_DIV

public static final int OP_DIV
Calculator division.

See Also:
Constant Field Values

OP_MUL

public static final int OP_MUL
Calculator multiplication.

See Also:
Constant Field Values

OP_ADD

public static final int OP_ADD
Calculator addition.

See Also:
Constant Field Values

OP_SUB

public static final int OP_SUB
Calculator subtraction.

See Also:
Constant Field Values

DOT

public static final int DOT
Calculator decimal point.

See Also:
Constant Field Values

EQUALS

public static final int EQUALS
Calculator = button.

See Also:
Constant Field Values

CLEAR

public static final int CLEAR
Calculator clear button.

See Also:
Constant Field Values

LAST

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

See Also:
Constant Field Values

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.

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.

Calculator Problem Set Javadocs