Mining off camera

This commit is contained in:
Libkyy
2022-06-01 17:57:43 +02:00
parent aa5db3b5c3
commit 4e23bba87e
2 changed files with 88 additions and 1 deletions

View File

@@ -1,3 +1,62 @@
public class RecipeTree
{
private RecipeNode root;
public RecipeTree()
{
root = null;
}
public RecipeNode getRoot()
{
return root;
}
public void setRoot(RecipeNode root)
{
this.root = root;
}
public void DFS(String value)
{
DFS(root, value);
}
public void DFS(RecipeNode node, String value)
{
if(node == null)
{
System.out.println("Node not found");
return;
}
if(node.getIngredient().equals(value))
{
System.out.println(node.getIngredient() + " " + node.getPortion());
}
for(RecipeNode child : node.getChildren())
{
DFS(child, value);
}
}
public void addNode(RecipeNode parent, RecipeNode child)
{
if (parent == null)
{
root = child;
}
else
{
parent.addChild(child);
}
}
public void printTree()
{
if (root != null)
{
root.printNode();
}
}
}