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

Variable Index

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

Method Index

 o getButton()
Get the next Button pressed.
 o getText()
Get the text currently displayed on the Calculator.
 o setText(String)
Set the text currently displayed on the Calculator.

Variables

 o NO_OP
 public static final int NO_OP
No operation in progress.

 o OP_DIV
 public static final int OP_DIV
Calculator division.

 o OP_MUL
 public static final int OP_MUL
Calculator multiplication.

 o OP_ADD
 public static final int OP_ADD
Calculator addition.

 o OP_SUB
 public static final int OP_SUB
Calculator subtraction.

 o DOT
 public static final int DOT
Calculator decimal point.

 o EQUALS
 public static final int EQUALS
Calculator = button.

 o CLEAR
 public static final int CLEAR
Calculator clear button.

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

 o 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).

Methods

 o 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.
 o getText
 public abstract String getText()
Get the text currently displayed on the Calculator.

Returns:
the text as a String.
 o 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