Source of DecisionTreeInterface.java


  1: package TreePackage;
  2: /**
  3:    An interface for a decision tree.
  4:    
  5:    @author Frank M. Carrano
  6:    @author Timothy M. Henry
  7:    @version 4.0
  8: */
  9: public interface DecisionTreeInterface<T> extends BinaryTreeInterface<T>
 10: {
 11:    /** Gets the data in the current node.
 12:        @return  The data object in the current node, or
 13:                 null if the current node is null. */
 14:    public T getCurrentData();
 15: 
 16:    /** Sets the data in the current node.
 17:        Precondition: The current node is not null. 
 18:        @param newData  The new data object. */
 19:    public void setCurrentData(T newData);
 20: 
 21:    /** Sets the data in the children of the current node,
 22:        creating them if they do not exist.
 23:        Precondition: The current node is not null. 
 24:        @param responseForNo   The new data object for the left child.
 25:        @param responseForYes  The new data object for the right child. */
 26:    public void setResponses(T responseForNo, T responseForYes);
 27: 
 28:    /** Sees whether the current node contains an answer.
 29:       @return  True if the current node is a leaf, or
 30:                false if it is a nonleaf. */
 31:    public boolean isAnswer();
 32: 
 33:    /** Sets the current node to its left child.
 34:        If the child does not exist, sets the current node to null.
 35:        Precondition: The current node is not null. */
 36:    public void advanceToNo();
 37: 
 38:    /** Sets the current node to its right child.
 39:        If the child does not exist, sets the current node to null.
 40:        Precondition: The current node is not null. */
 41:    public void advanceToYes();
 42: 
 43:    /** Makes the root of the tree the current node. */
 44:    public void resetCurrentNode();
 45: } // end DecisionTreeInterface