|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--EDU.ksu.cis.calculator.defaultmodel.CalculatorImpl
A model for an RPN calculator using the
LargeInteger
class.
Constructor Summary | |
CalculatorImpl(CalculatorUI v)
Constructs a new CalculatorImpl using the given user interface, base 10, and sticky bases. |
|
CalculatorImpl(CalculatorUI v,
boolean s)
Constructs a new CalculatorImpl using the given user interface and the given setting for sticky bases, in base 10. |
|
CalculatorImpl(CalculatorUI v,
int b)
Constructs a new CalculatorImpl using the given user interface and base, with sticky bases. |
|
CalculatorImpl(CalculatorUI v,
int b,
boolean s)
Constructs a new CalculatorImpl using the given user interface, base, and setting for sticky bases. |
Method Summary | |
void |
changeSettings(Object change,
String input)
Changes the settings of the calculator. |
void |
doOperation(Operation op,
String input)
Performs the given operation. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public CalculatorImpl(CalculatorUI v)
public CalculatorImpl(CalculatorUI v, int b)
public CalculatorImpl(CalculatorUI v, boolean s)
public CalculatorImpl(CalculatorUI v, int b, boolean s)
Method Detail |
public void doOperation(Operation op, String input) throws EmptyDequeException, NumberFormatException, Exception
The following classes of operations are supported:
Push
- If input is null, a copy of the top of the
stack is pushed. Otherwise, input is simply accepted as
the new top of the stack. Unrecognized subclasses of
Operation
are treated as Push.
Pop
- Removes the top from the stack.
ClearStack
- Empties the stack.
RotateUp
- Moves the element at the bottom of the stack to
the top.
RotateDown
- Moves the element at the top of the stack to the
bottom.
ConvertBase
- Converts the top of
the stack to the base specified by
op.getBase()
.
If the stack is empty, simply reports the new base to the user
interface.
EncodedOperation
- Performs the
operation specified by the given subclass of EncodedOperation.
doOperation
in interface Calculator
EmptyDequeException
- If the operation requires more operands
than are present on the stack.
NumberFormatException
- If input contains an invalid
character for the current base.
Exception
- If the given operation throws an
exception.public void changeSettings(Object change, String input)
Boolean
, then bases are set to sticky iff the
value of change is true. If change is of a different
type, this method has no effect. The second parameter is ignored.
changeSettings
in interface Calculator
change
- Encodes the change to the settings.input
- May contain input affected by the change.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |