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

Variable Index

 o buttonPanel
 o frame

Constructor Index

 o Calculator()
No-args constructor.

Method Index

 o getCumulator()
Getter method for cumulator attribute.
 o getEntryField()
Getter method for entry field attribute.
 o getLastButton()
Getter method for last button clicked attribute.
 o setCumulator(double)
Setter method for cumulator attribute.
 o setEntryField(String)
Setter method for entry field attribute.
 o setLastButton(CalculatorButton)
Setter method for last button clicked attribute.

Variables

 o buttonPanel
protected Panel buttonPanel
 o frame
protected Frame frame

Constructors

 o Calculator
public Calculator()
No-args constructor. Sets up the various calculator GUI components.

Methods

 o getCumulator
public final double getCumulator()
Getter method for cumulator attribute.

Returns:
current value of cumulator
 o setCumulator
public final void setCumulator(double cumulator)
Setter method for cumulator attribute.

Parameters:
cumulator - new value for cumulator
 o getEntryField
public final String getEntryField()
Getter method for entry field attribute.

Returns:
current value of entry field
 o setEntryField
public final void setEntryField(String value)
Setter method for entry field attribute.

Parameters:
value - new value for entry field
 o getLastButton
public final CalculatorButton getLastButton()
Getter method for last button clicked attribute.

Returns:
last button clicked
 o 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