All Packages Class Hierarchy This Package Previous Next Index
Class programming101.calculBeanz.Calculator
java.lang.Object
|
+----FR.essi.sander.graphix.mvc.ModelImpl
|
+----programming101.calculBeanz.Calculator
- public class Calculator
- extends ModelImpl
- implements ControlListener, Serializable
Defines a very simple calculator which combines a cumulative numeric
value with a new numeric value according to some operation.
The calculator as a whole rigorously applies the MVC (Model-View-Control)
"design pattern", where the calculator state is the model (that's this component),
the various buttons provide the control, and the display region is the
display (really!). Communication is by way of events, e.g., the
calculator (M component) registers itself as interested by button events
(the C components), and when a button is pushed the appropriate event gets sent to the
calculator which then calculates and posts an event to the display (the V component).
This has the advantage of being modular, with each component in fact being a JavaBean.
This class
extends FR.essi.sander.graphix.mvc.ModelImpl
superclass supplies management for ModelListener
s so we don't have to
implements FR.essi.sander.graphix.mvc.ControlListener
guarantees code for the update
method which is invoked by control events
implements java.io.Serializable
needed for JavaBeans
- Since:
- 18/03/98
- Version:
- 1.2 (6/04/98)
- Author:
- © 1998 Peter T. Sander
Calculator()
- No-args constructor (needed for JavaBeans).
getCumulator()
- Getter method for cumulator attribute.
update(ControlEvent)
- Method guaranteed by implementing the
ControlListener
interface.
Calculator
public Calculator()
- No-args constructor (needed for JavaBeans).
update
public void update(ControlEvent ce)
- Method guaranteed by implementing the
ControlListener
interface. Invoked by any controls which have registered this
calculator as interested by their events.
- Parameters:
- ce - a control button event
- Overrides:
- update in class ModelImpl
getCumulator
public double getCumulator()
- Getter method for cumulator attribute.
- Returns:
- cumulator value
All Packages Class Hierarchy This Package Previous Next Index