Class Calculator
java.lang.Object
calculator.Calculator
This class represents the core logic of a Calculator.
It can be used to print and evaluate artihmetic expressions.
- Author:
- tommens
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioneval(Expression e) Evaluates an arithmetic expression and returns its resultformat(Expression e, Notation notation) Formats an arithmetic expression in a given notationvoidprint(Expression e) Prints an arithmetic expression provided as input parameter.voidPrints verbose details of an arithmetic expression provided as input parameter.
-
Constructor Details
-
Calculator
public Calculator()Default constructor of the class. Does nothing since the class does not have any variables that need to be initialised.
-
-
Method Details
-
print
Prints an arithmetic expression provided as input parameter.- Parameters:
e- the arithmetic Expression to be printed- See Also:
-
printExpressionDetails
Prints verbose details of an arithmetic expression provided as input parameter.- Parameters:
e- the arithmetic Expression to be printed- See Also:
-
eval
Evaluates an arithmetic expression and returns its result- Parameters:
e- the arithmetic Expression to be evaluated- Returns:
- The result of the evaluation
-
format
Formats an arithmetic expression in a given notation- Parameters:
e- the arithmetic Expression to be formattednotation- the notation to be used for formatting- Returns:
- The formatted expression as a String
-