Class infixModel.InfixCalc
- public class InfixCalc
- extends Object
Represents the calculator itself, without its GUI and separate from its states.
Copyright (C) 2004 Dung X. Nguyen. All rights Reserved.

_acc
- accumulated computation
_curState
- The current state
_display
- current display string
_noOp
- A no-op
_pendingOp
- Current pending operation

InfixCalc
()
- Inialize this Calculator to the "clear" state

clear
()
- Set this Calculator to the "clear" state where all internal memories are
enterDigit
(char)
- Enters a digit
enterEqual
()
- Compute the current operation and return the result String
enterOp
(IBinOp)
- Perform the pending operation, and prepare to add whatever is computed so
enterPoint
()
- Enters a decimal point
getAcc
()
- Gets the current accumulator value
getCurState
()
- Get the current state
getDisplay
()
- Get the current display string
getPendingOp
()
- Get the pending operation
setAcc
(double)
- Sets the accumulator value
setCurState
(ACalcState)
- Sets the current state
setDisplay
(String)
- Sets the display string
setNoOp
()
- Sets the pending operation to a no-op
setPendingOp
(IBinOp)
- Sets the pending operation

_acc
private double _acc
- accumulated computation
_display
private String _display
- current display string
_pendingOp
private IBinOp _pendingOp
- Current pending operation
_noOp
private final IBinOp _noOp = new IBinOp() {
public double compute(double n1, double n2) {
return Double.parseDouble(_display);
}
}
- A no-op
_curState
private ACalcState _curState
- The current state

InfixCalc
public InfixCalc()
- Inialize this Calculator to the "clear" state.

enterDigit
public final String enterDigit(char c)
- Enters a digit.
- Parameters:
- c - '0' <= c <= '9'.
- Returns:
- accumulated input.
enterPoint
public final String enterPoint()
- Enters a decimal point
enterOp
public final String enterOp(IBinOp op)
- Perform the pending operation, and prepare to add whatever is computed so
far to the operand that will be entered next and return the resulting String.
- Parameters:
- op - The new pending operation.
enterEqual
public final String enterEqual()
- Compute the current operation and return the result String.
clear
public final String clear()
- Set this Calculator to the "clear" state where all internal memories are
set to zero and the pending operation is a no-op.
getAcc
final double getAcc()
- Gets the current accumulator value
- Returns:
- The current accumulator value
setAcc
final void setAcc(double a)
- Sets the accumulator value
- Parameters:
- a - The new accumulator value
setDisplay
final void setDisplay(String d)
- Sets the display string
- Parameters:
- d - The new display string
getDisplay
final String getDisplay()
- Get the current display string
- Returns:
- The current display string
setPendingOp
final void setPendingOp(IBinOp op)
- Sets the pending operation
- Parameters:
- op - The new pending operation
getPendingOp
final IBinOp getPendingOp()
- Get the pending operation
*
- Returns:
- The pending operation
setNoOp
final void setNoOp()
- Sets the pending operation to a no-op
setCurState
final void setCurState(ACalcState curState)
- Sets the current state.
- Parameters:
- curState - The new current state
getCurState
final ACalcState getCurState()
- Get the current state
- Returns:
- The current state