Class UnaryFunction
java.lang.Object
calculator.functions.UnaryFunction
- All Implemented Interfaces:
Expression
- Direct Known Subclasses:
Arccosinus, Arcsinus, Arctangente, Cosh, Cosinus, Ln, Sinh, Sinus, Sqrt, Tangente, Tanh
UnaryFunction is an abstract class that represents unary arithmetic
operations,
which are a special kind of Expressions, just like binary operations are.
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe expression passed as an argument to the arithmetic operationprotected StringThe character/string used to represent the arithmetic operation (e.g. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedUnaryFunction(Expression arg) To construct a unary operation with an expression as argument -
Method Summary
Modifier and TypeMethodDescriptionvoidAccept method to implement the visitor design pattern to traverse arithmetic expressions.booleangetArg()getter method to return the argument of an arithmetic operation.getter method to return the symbol of the arithmetic operation.inthashCode()abstract Complexabstract IntegerAtomop(IntegerAtom i) abstract Rationnalabstract Realfinal StringtoString()final String
-
Field Details
-
arg
The expression passed as an argument to the arithmetic operation -
symbol
The character/string used to represent the arithmetic operation (e.g. "cos")
-
-
Constructor Details
-
UnaryFunction
To construct a unary operation with an expression as argument- Parameters:
arg- The expression passed as argument to the arithmetic operation- Throws:
IllegalConstruction- Exception thrown if a null argument is passed
-
-
Method Details
-
getArg
getter method to return the argument of an arithmetic operation.- Returns:
- The argument of the arithmetic operation.
-
getSymbol
getter method to return the symbol of the arithmetic operation.- Returns:
- The symbol of the arithmetic operation.
-
op
-
op
-
op
-
op
-
accept
Accept method to implement the visitor design pattern to traverse arithmetic expressions.- Specified by:
acceptin interfaceExpression- Parameters:
v- The visitor object
-
toString
-
toString
-
equals
-
hashCode
-