-
Notifications
You must be signed in to change notification settings - Fork 0
/
BaseExpression.java
34 lines (29 loc) · 1.17 KB
/
BaseExpression.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import java.util.ArrayList;
import java.util.List;
/**
* BaseExpression represents complex expressions which are formed from one expression or more.
* @author Yossi Maatook.
*/
public abstract class BaseExpression implements Expression {
/**
* Returns the sign of the Expression(it's logical symbol).
* @return Returns the sign of the Expression(it's logical symbol).
*/
protected abstract String getExpressionSign();
/**
* Returns a list with the expressions which are forming the BaseExpression.
* @return list with the expressions which are forming the BaseExpression.
*/
protected abstract ArrayList<Expression> getExpressions();
@Override
public List<String> getVariables() {
//Get list of the expression forming the BaseExpression//
ArrayList<Expression> expressions = getExpressions();
ArrayList<String> variables = new ArrayList<>();
//Add the variables from each expression to the list//
for (Expression e:expressions) {
variables.addAll(e.getVariables());
}
return new ListActions().removeDuplicates(variables);
}
}