All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class Calculator.ButtonObj

java.lang.Object
   |
   +----Calculator.ButtonObj

public class ButtonObj
extends Object
An instance of this class is a smart button object that knows how to handle itself. There should be one for each button on the Calculator. The ButtonHandler will activate each ButtonObj as its button is pressed.

This class is a pretty generic button handler; it doesn't do anything. Its subclasses should override handleButton() to make it do something interesting. The fields of this class are protected (rather than private) precisely to allow access in these overridden methods.

Each ButtonObj knows about the Calculator (or at any rate a text interface to the Calculator) and its state.

It might be reasonable to declare this class abstract.

See Also:
Calculator

Variable Index

 o gui
The Calculator-adaptor that this instance can use to get and set text.
 o stateObj
The CalculatorState that keeps track of what's going on in the behavior of the Calculator that this ButtonObj belongs to.

Constructor Index

 o ButtonObj(CalcTextGUI, CalculatorState)
How to make one: tell it what GUI and what state object it's working with.

Method Index

 o handleButton()
How to handle a button.

Variables

 o gui
 protected CalcTextGUI gui
The Calculator-adaptor that this instance can use to get and set text. Initialized in constructor; shouldn't change.

 o stateObj
 protected CalculatorState stateObj
The CalculatorState that keeps track of what's going on in the behavior of the Calculator that this ButtonObj belongs to. Initialized in constructor; shouldn't change.

Constructors

 o ButtonObj
 public ButtonObj(CalcTextGUI gui,
                  CalculatorState stateObj)
How to make one: tell it what GUI and what state object it's working with. It will remember these for future use.

Parameters:
gui - The CalcTextGUI to keep track of.
stateObj - The CalculatorState to keep track of.

Methods

 o handleButton
 public void handleButton()
How to handle a button. (In this case, don't do much. Subclasses will override.)


All Packages  Class Hierarchy  This Package  Previous  Next  Index