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();
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

View File

@@ -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 + "]";
}
}
}

View File

@@ -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;
}