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
-
gui
- The Calculator-adaptor that this instance can use to get and set
text.
-
stateObj
- The CalculatorState that keeps track of what's going on in the
behavior of the Calculator that this ButtonObj belongs to.
-
ButtonObj(CalcTextGUI,
CalculatorState)
- How to make one: tell it what GUI and what state object it's working
with.
-
handleButton()
- How to handle a button.
gui
protected CalcTextGUI gui
- The Calculator-adaptor that this instance can use to get and set
text. Initialized in constructor; shouldn't change.
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.
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.
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