-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForNode.java
More file actions
41 lines (35 loc) · 1.09 KB
/
ForNode.java
File metadata and controls
41 lines (35 loc) · 1.09 KB
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
35
36
37
38
39
40
41
package icsi311;
import java.util.LinkedList;
public class ForNode extends StatementNode{
private LinkedList<Node> Condition;
private BlockNode Block;
// If true, then don't print out block. This is to avoid erorrs
private boolean emptyBlock = false;
public ForNode(LinkedList<Node> l, BlockNode b){
Block = b;
Condition = l;
}
public ForNode(LinkedList<Node> l){
Condition = l;
emptyBlock = true;
}
public String toString(){
// If true, don't call or mention block
if(emptyBlock == true)
return "for(" + ConditionListToString() + "){}";
return "\nfor(" + ConditionListToString() + "){\n\t" + Block.toString() + "\n}\n";
}
public LinkedList<Node> getCondition(){
return Condition;
}
public String ConditionListToString(){
String f = "";
for(int i = 0; i < Condition.size(); i++)
f += Condition.get(i).toString() + ", ";
f = f = f.substring(0,f.length()-2);
return f;
}
public BlockNode getBlock(){
return Block;
}
}