Class infixModel.ACalcState


abstract class ACalcState
extends Object
Represents the abstract state of the calculator (the context)


Variable Index

 o ErrorState
An error state object for general use

Method Index

 o enterDigit (InfixCalc, char)
Appends c to the string of digit collected so far
 o enterEqual (InfixCalc)
Computes the pending operation
 o enterOp (InfixCalc, IBinOp)
Performs the pending operation, and set op as the next pending operation
 o enterPoint (InfixCalc)
Enters a decimal point

Variables

 o ErrorState
static final ACalcState ErrorState = new ACalcState() { // state 3 is error state: null-object pattern, does nothing!
    public void enterDigit(InfixCalc calc, char c) {
    }
    
    public void enterOp(InfixCalc calc, IBinOp op) {
    }
    
    public void enterEqual(InfixCalc calc) {
    }
    
    public void enterPoint(InfixCalc calc) {
    }
  }
An error state object for general use A null object, does nothing.

Methods

 o enterDigit
public abstract void enterDigit(InfixCalc calc, char c)
Appends c to the string of digit collected so far.

Parameters:
calc - The calculator model (context)
c - The digit being entered
 o enterOp
public abstract void enterOp(InfixCalc calc, IBinOp op)
Performs the pending operation, and set op as the next pending operation on whatever is computed so far to the operand that will be entered next.

Parameters:
calc - The calculator model (context)
op - The new pendin operation
 o enterEqual
public abstract void enterEqual(InfixCalc calc)
Computes the pending operation.

Parameters:
calc - The calculator model (context)
 o enterPoint
public abstract void enterPoint(InfixCalc calc)
Enters a decimal point.

Parameters:
calc - The calculator model (context)