1 package calculator.atoms;
2
3 import calculator.Expression;
4 import calculator.operations.Operation;
5 import calculator.atoms.visitor.AtomVisitor;
6 import calculator.functions.BinaryFunction;
7 import calculator.functions.UnaryFunction;
8
9 /**
10 * Atom abstract class
11 * An Atom represents a number (or an operand of operations).
12 * The implemented number (atom) types are present in the AtomType enum
13 *
14 * @see AtomType
15 */
16 public interface Atom extends Expression {
17
18 /**
19 * Applies an operation between two atoms of the same concrete type
20 * The function supposes that both atoms are of the same concrete type
21 *
22 * @see AtomType
23 *
24 * @param o the operation to apply
25 * @param a the other atom
26 * @return the result of the operation having the same type as a
27 */
28 public Atom apply(Operation o, Atom a);
29
30 /**
31 * Applies an Binary between two atoms of the same concrete type
32 * The function supposes that both atoms are of the same concrete type
33 *
34 * @see AtomType
35 *
36 * @param f the binary function to with this atom as first parameter
37 * @param a the other atom
38 * @return the result of the operation having the same type as a
39 */
40 public Atom apply(BinaryFunction f, Atom a);
41
42 /**
43 * Applies an operation on the atom
44 *
45 * @param o the unary operation to apply
46 * @return the result of the operation
47 */
48 public Atom apply(UnaryFunction o);
49
50 /**
51 * accepts the specific AtomVisitor
52 *
53 * @param aV The Atomvisitor object being passed as a parameter
54 */
55 public void accept(AtomVisitor aV);
56 }