import java.util.EmptyStackException; import java.util.Stack; public class Tree { Stack<Node> nodeStack = new Stack<Node>(); public Tree(){ nodeStack = null; } void setTasks( Node Nodes){ try{ nodeStack.push(Nodes); } catch (Exception e){ e.printStackTrace(); } } void runTasks(){ Node node = (Node) nodeStack.peek(); if(nodeStack!=null){ node.execute(); } else{ throw new EmptyStackException(); } } }
public abstract class Node { public boolean condition(){ return false; } public void execute(){ } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)