Compare commits
2 Commits
switch-mai
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| bbb5f1d092 | |||
|
|
ceaeb627e5 |
@@ -20,10 +20,11 @@ public class RecipeInstructions
|
||||
userInstruction = userInput.nextLine();
|
||||
|
||||
RecipeCreation(userInstruction,fullInstructions);
|
||||
fullInstructions.printTree();
|
||||
System.out.println(fullInstructions.sortTopology());
|
||||
|
||||
} while(!userInstruction.equalsIgnoreCase("done"));
|
||||
|
||||
|
||||
System.out.println(fullInstructions.sortTopology());
|
||||
System.out.println("Thank you for using recipe constructor.");
|
||||
}
|
||||
|
||||
//Magical Regex
|
||||
|
||||
@@ -58,6 +58,10 @@ public class RecipeNode {
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RecipeNode [ingredient=" + ingredient + ", portion=" + portion + "]";
|
||||
if(portion != 0) {
|
||||
return "[Ingredient: " + ingredient + ", portion = " + portion + " units]";
|
||||
} else {
|
||||
return "[Ingredient: " + ingredient + "]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,6 +118,10 @@ public class RecipeTree
|
||||
Stack<RecipeNode> stack = new Stack<RecipeNode>();
|
||||
stack.push(root);
|
||||
sortTopology(root, stack);
|
||||
|
||||
for(RecipeNode node : stack) {
|
||||
System.out.println(node);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user