Compare commits

2 Commits

Author SHA1 Message Date
bbb5f1d092 Presumed final, print feels wonky-ish 2022-06-02 22:54:23 +02:00
Mjørk
ceaeb627e5 Merge pull request #5 from LinlyBoi/switch-main
Switch main
2022-06-02 22:41:17 +02:00
3 changed files with 13 additions and 4 deletions

View File

@@ -20,10 +20,11 @@ public class RecipeInstructions
userInstruction = userInput.nextLine(); userInstruction = userInput.nextLine();
RecipeCreation(userInstruction,fullInstructions); RecipeCreation(userInstruction,fullInstructions);
fullInstructions.printTree();
System.out.println(fullInstructions.sortTopology());
} while(!userInstruction.equalsIgnoreCase("done")); } while(!userInstruction.equalsIgnoreCase("done"));
System.out.println(fullInstructions.sortTopology());
System.out.println("Thank you for using recipe constructor.");
} }
//Magical Regex //Magical Regex

View File

@@ -58,6 +58,10 @@ public class RecipeNode {
} }
@Override @Override
public String toString() { public String toString() {
return "RecipeNode [ingredient=" + ingredient + ", portion=" + portion + "]"; if(portion != 0) {
return "[Ingredient: " + ingredient + ", portion = " + portion + " units]";
} else {
return "[Ingredient: " + ingredient + "]";
}
} }
} }

View File

@@ -118,6 +118,10 @@ public class RecipeTree
Stack<RecipeNode> stack = new Stack<RecipeNode>(); Stack<RecipeNode> stack = new Stack<RecipeNode>();
stack.push(root); stack.push(root);
sortTopology(root, stack); sortTopology(root, stack);
for(RecipeNode node : stack) {
System.out.println(node);
}
return stack; return stack;
} }