Presumed final, print feels wonky-ish

This commit is contained in:
2022-06-02 22:54:23 +02:00
parent ceaeb627e5
commit bbb5f1d092
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;
}