Failed action adder
This commit is contained in:
@@ -54,7 +54,7 @@ public class RecipeInstructions
|
||||
String[] words = split[1].split(" ");
|
||||
construct_children(newAction, words);
|
||||
//we add the thing to the tree (this also needs to be checked for WHERE it gets added)
|
||||
fullInstructions.addNode((RecipeNode) null, newAction);
|
||||
fullInstructions.actionAdd(newAction);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -130,5 +130,19 @@ public class RecipeTree
|
||||
}
|
||||
}
|
||||
|
||||
public void actionAdd(RecipeNode actionNchild) {
|
||||
if(root == null) {
|
||||
root = actionNchild;
|
||||
} else {
|
||||
for(RecipeNode node : root.children) {
|
||||
if(node.getPortion() != 0 || !actionNchild.getIngredient().equals(node.getIngredient())) {
|
||||
actionAdd(actionNchild);
|
||||
} else if(node.getPortion() == 0 && actionNchild.getIngredient().equals(node.getIngredient())) {
|
||||
actionNchild.parent = node.parent;
|
||||
node.parent = actionNchild;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user