/// <summary> /// Sets the left and right nodes of our curNode to the first two letters of our prefix accordingly /// Uses recursives methods if certain conditions are met /// </summary> /// <param name="curNode">Either the root of the equation or a branch</param> /// <param name="Prefix">Prefix input from the text file</param> public void TreeBuilder(Node curNode, string Prefix) { //Create a new node for the current nodes left branch to Node leftNode = new Node(Prefix.Substring(count, 1)); curNode.SetLeft(leftNode); count++; //Call TreeBuilder again if the left branch is an operation //Sets the TreeBuilder parameter to the current node's left branch asa well as the same prefix if (leftNode.GetCargo() == "+" || leftNode.GetCargo() == "-" || leftNode.GetCargo() == "*" || leftNode.GetCargo() == "/" || leftNode.GetCargo() == "^") { TreeBuilder(curNode.GetNextL(), Prefix); } //Create a new node for the current nodes right branch to Node rightNode = new Node(Prefix.Substring(count, 1)); curNode.SetRight(rightNode); count++; //Call TreeBuilder again if the right branch is an operation //Sets the TreeBuilder parameter to the current node's right branch asa well as the same prefix if (rightNode.GetCargo() == "+" || rightNode.GetCargo() == "-" || rightNode.GetCargo() == "*" || rightNode.GetCargo() == "/" || rightNode.GetCargo() == "^") { TreeBuilder(curNode.GetNextR(), Prefix); } }