Class Accumulator

java.lang.Object
  |
  +--Accumulator

public class Accumulator
extends java.lang.Object

Class to keep track of the state of an adding machine. It accumulates digits to form entire numbers and either adds or subtracts those numbers to a cumulative sum. It also has a reset option.

Author:
Stuart Reges

Constructor Summary
Accumulator()
           
 
Method Summary
 void addDigit(int digit)
          Adds the given digit to the end of the number currently being entered.
 void clear()
          Resets the currently displayed and accumulated values to zero.
 int getDisplay()
          Retrieves the value to be displayed.
 void minus()
          Substracts the current number from the accumulated value.
 void plus()
          Adds the current number to the accumulated value.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Accumulator

public Accumulator()
Method Detail

clear

public void clear()
Resets the currently displayed and accumulated values to zero.


addDigit

public void addDigit(int digit)
Adds the given digit to the end of the number currently being entered.

Parameters:
digit - The digit to be appended to the end of the current number.

plus

public void plus()
Adds the current number to the accumulated value.


minus

public void minus()
Substracts the current number from the accumulated value.


getDisplay

public int getDisplay()
Retrieves the value to be displayed.

Returns:
the value to be displayed.