Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- public class Node{
- public ArrayList<Node> childNode;
- private int estimatedScore;
- public Node(){
- childNode = new ArrayList<Node>();
- }
- public int getScore()
- {
- return estimatedScore;
- }
- public void setScore(int estimatedScore)
- {
- this.estimatedScore = estimatedScore;
- }
- public void addChildNode(Node n){
- childNode.add(n);
- }
- public String toString(){
- return "-- Node:"+ estimatedScore+"--";
- }
- public void buildTree(int depth){
- System.out.println("(" + estimatedScore + ")");
- for(int j=0; j<childNode.size(); j++){
- if(this.values()){
- for(int k=0; k<depth; k++){
- System.out.println("\t");
- }
- childNode.get(j).buildTree(depth+1);
- }
- else System.out.println("(" + estimatedScore +")");
- }
- }
- public boolean values(){
- if(childNode.size()>0) return true;
- else return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement