Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

///// The implementation is a tree of sub-trees, so each tree instance is a node

ID: 3619632 • Letter: #

Question

/////
  • The implementation is a tree of sub-trees, so each tree instance is a node that is the root of its own tree.
  • There is no setBoard(). The Board should be set on construction of the Tree, and never change (i.e. is final).
  • All Trees have a getter and setter for a score value, but only leaves must have scores. Use of these in non-leaves is not required.
  • Since Trees are comparable, you can define what it means for a Tree to be "before", "the same as", or "after" another Tree. This should be defined using only the properties of the tree root, and not any children.
  • When writing equals(), only consider the properties of the tree root, and not any children.
  • equals() == true and compareTo() == 0 need not mean the same thing.
  • The size() method of tree refers to the size of the number of direct children.
/////
} package csci1902.project5.ai;

import csci1902.project5.ai.TreeInterface;
import csci1902.project5.tetris.Board;
import java.util.List;
import javax.swing.tree.TreeNode;

/**
*
* @author kiran
*/
public class Tree implements TreeInterface {
  
//private String nodeValue;
//private List<Tree> subTrees;
private TreeNode parent = null;
private List children = null;
private Object refer;



    public Board getBoard() {
         if (Board == null) {
            Board = new Board();
        }
        return (Board) Board;
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void addChild(Tree child) {
        child.parent = (TreeNode) this;
        if(!children.contains(child)){
            children.add(child);
   
    }
    }
    public Tree getChild(int pos) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public double getScore() {
         int Score = 0;
    TreeNode p = parent;
    while (p != null) {
      ++Score;
      p = p.getParent();
    }
    return Score;
}
      
  

    public void setScore(double score) {
       throw new UnsupportedOperationException("Not supported yet.");
    }

    public boolean isLeaf() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public int size() {
    
return(size());
}

private int size(T entry) {
if (entry != null)
      return(size(left) + 1 + size(right));
else {
   return ();
}

      
    }

    public int compareTo(Object o) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

}


/////
  • The implementation is a tree of sub-trees, so each tree instance is a node that is the root of its own tree.
  • There is no setBoard(). The Board should be set on construction of the Tree, and never change (i.e. is final).
  • All Trees have a getter and setter for a score value, but only leaves must have scores. Use of these in non-leaves is not required.
  • Since Trees are comparable, you can define what it means for a Tree to be "before", "the same as", or "after" another Tree. This should be defined using only the properties of the tree root, and not any children.
  • When writing equals(), only consider the properties of the tree root, and not any children.
  • equals() == true and compareTo() == 0 need not mean the same thing.
  • The size() method of tree refers to the size of the number of direct children.
/////
  • The implementation is a tree of sub-trees, so each tree instance is a node that is the root of its own tree.
  • There is no setBoard(). The Board should be set on construction of the Tree, and never change (i.e. is final).
  • All Trees have a getter and setter for a score value, but only leaves must have scores. Use of these in non-leaves is not required.
  • Since Trees are comparable, you can define what it means for a Tree to be "before", "the same as", or "after" another Tree. This should be defined using only the properties of the tree root, and not any children.
  • When writing equals(), only consider the properties of the tree root, and not any children.
  • equals() == true and compareTo() == 0 need not mean the same thing.
  • The size() method of tree refers to the size of the number of direct children.
package csci1902.project5.ai;

import csci1902.project5.ai.TreeInterface;
import csci1902.project5.tetris.Board;
import java.util.List;
import javax.swing.tree.TreeNode;

/**
*
* @author kiran
*/
public class Tree implements TreeInterface {
  
//private String nodeValue;
//private List<Tree> subTrees;
private TreeNode parent = null;
private List children = null;
private Object refer;



    public Board getBoard() {
         if (Board == null) {
            Board = new Board();
        }
        return (Board) Board;
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void addChild(Tree child) {
        child.parent = (TreeNode) this;
        if(!children.contains(child)){
            children.add(child);
   
    }
    }
    public Tree getChild(int pos) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public double getScore() {
         int Score = 0;
    TreeNode p = parent;
    while (p != null) {
      ++Score;
      p = p.getParent();
    }
    return Score;
}
      
  

    public void setScore(double score) {
       throw new UnsupportedOperationException("Not supported yet.");
    }

    public boolean isLeaf() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public int size() {
    
return(size());
}

private int size(T entry) {
if (entry != null)
      return(size(left) + 1 + size(right));
else {
   return ();
}

      
    }

    public int compareTo(Object o) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

}

Explanation / Answer

X