Class IntegerAtom
java.lang.Object
calculator.atoms.IntegerAtom
- All Implemented Interfaces:
Atom, Expression
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept method to implement the visitor design pattern to traverse Atoms.voidaccept method to implement the visitor design pattern to traverse arithmetic expressions.apply(BinaryFunction f, Atom a) Applies an Binary between two atoms of the same concrete type The function supposes that both atoms are of the same concrete typeapplies a unary operation to the IntegerAtomapplies an operation between two IntegerAtombooleanTwo Integers Atoms are equal if the values they contain are equalintgetValue()returns the value of the integerinthashCode()The method hashCode needs to be overridden it the equals method is overridden; otherwise there may be problems when you use your object in hashed collections such as HashMap, HashSet, LinkedHashSet.toString()
-
Constructor Details
-
IntegerAtom
public IntegerAtom(int i) Constructor method- Parameters:
i- The integer value
-
-
Method Details
-
accept
accept method to implement the visitor design pattern to traverse Atoms. Each Integer will pass itself to the Atomvisitor object to get processed by the Atomvisitor. -
accept
accept method to implement the visitor design pattern to traverse arithmetic expressions. Each Integer number will pass itself to the visitor object to get processed by the visitor.- Specified by:
acceptin interfaceExpression- Parameters:
v- The visitor object
-
equals
-
hashCode
-
apply
-
apply
applies a unary operation to the IntegerAtom -
apply
Description copied from interface:AtomApplies an Binary between two atoms of the same concrete type The function supposes that both atoms are of the same concrete type -
getValue
public int getValue()returns the value of the integer- Returns:
- the value of the integer
-
toString
-