Class infixModel.CompState


class CompState
extends infixModel.ACalcState
State where the calculator has computed a result


Variable Index

 o Singleton
Singleton instance

Constructor Index

 o CompState ()
Hidden constructor

Method Index

 o enterDigit (InfixCalc, char)
Appends c to the string of digit collected so far if not zero
 o enterEqual (InfixCalc)
Syntax error
 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 Singleton
public static final CompState Singleton = new CompState()
Singleton instance

Constructors

 o CompState
private  CompState()
Hidden constructor

Methods

 o enterDigit
public void enterDigit(InfixCalc calc, char c)
Appends c to the string of digit collected so far if not zero. If zero, then set display to "0" and return to start state.

Parameters:
calc - The calculator model (context)
c - The digit being entered
 o enterOp
public 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. Go to error if the number in the display does not parse properly into a floating point number.

Parameters:
calc - The calculator model (context)
op - New pending operation
 o enterEqual
public void enterEqual(InfixCalc calc)
Syntax error. Set display to "Syntax error" and go to error state.

Parameters:
calc - The calculator model (context)
 o enterPoint
public void enterPoint(InfixCalc calc)
Enters a decimal point. Set display ot "0." and go to point state.

Parameters:
calc - The calculator model (context)