All Packages Class Hierarchy This Package Previous Next Index
Class programming101.calculator.Calculator
java.lang.Object
|
+----programming101.calculator.Calculator
- public class Calculator
- extends Object
- implements Serializable
Defines a simple graphic calculator consisting of a display region
for accepting input and displaying results, and a number of buttons
for various operations. The buttons respond "directly" when they are clicked.
They receive a standard ActionEvent
from the
underlying windowing system. They also need information about the
state of the calculator - among other things, the
current cumulated value, the new value to be combined with the
cumulated value, the last button clicked, etc., and this must be
made accessible separately (in this case, through the constructors,
or an accessor method). The only buttons supplied here are:
ClearButton
, EqButton
, PlusButton
.
- Since:
- 15/03/98
- Version:
- 1.3 (7/04/98)
- Author:
- © 1998 Peter T. Sander
buttonPanel-
frame-
Calculator()
- No-args constructor.
getCumulator()
- Getter method for cumulator attribute.
getEntryField()
- Getter method for entry field attribute.
getLastButton()
- Getter method for last button clicked attribute.
setCumulator(double)
- Setter method for cumulator attribute.
setEntryField(String)
- Setter method for entry field attribute.
setLastButton(CalculatorButton)
- Setter method for last button clicked attribute.
buttonPanel
protected Panel buttonPanel
frame
protected Frame frame
Calculator
public Calculator()
- No-args constructor. Sets up the various calculator GUI components.
getCumulator
public final double getCumulator()
- Getter method for cumulator attribute.
- Returns:
- current value of cumulator
setCumulator
public final void setCumulator(double cumulator)
- Setter method for cumulator attribute.
- Parameters:
- cumulator - new value for cumulator
getEntryField
public final String getEntryField()
- Getter method for entry field attribute.
- Returns:
- current value of entry field
setEntryField
public final void setEntryField(String value)
- Setter method for entry field attribute.
- Parameters:
- value - new value for entry field
getLastButton
public final CalculatorButton getLastButton()
- Getter method for last button clicked attribute.
- Returns:
- last button clicked
setLastButton
public final void setLastButton(CalculatorButton lastButton)
- Setter method for last button clicked attribute.
- Parameters:
- lastButton - new value for last button clicked
All Packages Class Hierarchy This Package Previous Next Index