Class CalculatorChip

java.lang.Object
  |
  +--CalculatorChip

public class CalculatorChip
extends java.lang.Object

Provides the basic operations for a four-function, octal/decimal/hexadecimal calculator.

Version:
October 31, 2001
Author:
David Matuszek

Constructor Summary
CalculatorChip()
           
 
Method Summary
(package private)  java.lang.String clearAll()
          Completely resets the calculator.
(package private)  java.lang.String clearEntry()
          Zeros the number in the display, but otherwise leaves the calculator in the same state that it was in.
(package private)  java.lang.String digitClick(char digitChar)
          Starts the display with the digit or appends it to the number already in the display.
(package private)  java.lang.String equalsClick()
          Handles the equals key.
(package private)  java.lang.String operatorClick(char operator)
          Stores the operator (represented by one of the characters '+', '-', '*', or '/') so that it can be applied later to the operands.
(package private)  java.lang.String setBase(int base)
          Sets the calculator to display values in the given base, and returns the new display string.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CalculatorChip

public CalculatorChip()
Method Detail

clearAll

java.lang.String clearAll()
Completely resets the calculator.
Returns:
the string "0".

clearEntry

java.lang.String clearEntry()
Zeros the number in the display, but otherwise leaves the calculator in the same state that it was in.
Returns:
either an error message or the string "0".

digitClick

java.lang.String digitClick(char digitChar)
Starts the display with the digit or appends it to the number already in the display.
Parameters:
digitChar - a character representing the new digit.
Returns:
the string that should be displayed after appending the digit.

equalsClick

java.lang.String equalsClick()
Handles the equals key.
Returns:
the string to be displayed.

operatorClick

java.lang.String operatorClick(char operator)
Stores the operator (represented by one of the characters '+', '-', '*', or '/') so that it can be applied later to the operands.
Parameters:
operator - a character representing the operator to be stored.
Returns:
the string that should be displayed after storing the operator.

setBase

java.lang.String setBase(int base)
Sets the calculator to display values in the given base, and returns the new display string. The base must be one of the integers 8, 10, or 16.
Parameters:
base - the base to use, which must be 8, 10, or 16.
Returns:
the string to be displayed, representing the number in the new base.


Generated by BlueJ