Presumed final, print feels wonky-ish
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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 + "]";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user