Question: Can you please just fill in the sections that ask to add code or that asks to change code public class DecisionTree extends BinaryTree implements
Can you please just fill in the sections that ask to add code or that asks to change code
public class DecisionTree extends BinaryTree implements DecisionTreeInterface
private BinaryNode currentNode; Tracks where we are in the tree
public DecisionTree
Add code to here to inherit parent class
resetCurrentNode;
end default constructor
public DecisionTreeT rootData
Add code to here to inherit parent class
resetCurrentNode;
end constructor
Change the following code for DecisionTree as Binary Tree
public DecisionTree
Add code to here to inherit parent class
resetCurrentNode;
end constructor
public DecisionTreeT rootData, T responseForNo, T responseForYes
Change the following code for DecisionTree as BinaryTree responseForNo and responseForYes
Add code DecisionTree leftTree
Add code DecisionTree rightTree
Add code setTree;
resetCurrentNode;
end constructor
public T getCurrentData
if currentNode null
return currentNode.getData;
else
return null;
end getCurrentData
public void setCurrentDataT newData
if currentNode null
currentNode.setDatanewData;
else
throw new NullPointerException;
end setCurrentData
public void setResponsesT responseForNo, T responseForYes
if currentNode null
throw new NullPointerException;
else if currentNodehasLeftChild
Add code BinaryNode leftChild
leftChild.setDataresponseForNo;
else
Add code
Add code
end if
if currentNodehasRightChild
Add code BinaryNode rightChild
rightChild.setDataresponseForYes;
else
Add code BinaryNode newRightChild
currentNode.setRightChildnewRightChild;
end if
end setResponses
public boolean isAnswer
if currentNode null
return currentNode.isLeaf;
else
return false;
end isAnswer
public void advanceToNo
if currentNode null
throw new NullPointerException;
else
currentNode currentNode.getLeftChild;
end advanceToNo
public void advanceToYes
if currentNode null
throw new NullPointerException;
else
currentNode currentNode.getRightChild;
end advanceToYes
public void resetCurrentNode
currentNode getRootNode;
end resetCurrentNode
protected BinaryNode getCurrentNode
return currentNode;
end getCurrentNode
end DecisionTree
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
