Fill in the blanks.
toString()
Here are the completed methods along with a not-quite complete toString()
method.
// Forest.java // public class Forest { // instance variables private Tree tree0=null, tree1=null, tree2=null, tree3=null; // default constructor supplied automatically // methods public void setTree( int treeNum, Tree tree ) { if ( treeNum == 0 ) tree0 = tree; else if ( treeNum == 1 ) tree1 = tree; else if ( treeNum == 2 ) tree2 = tree; else if ( treeNum == 3 ) tree3 = tree; } public Tree getTree( int treeNum ) { if ( treeNum == 0 ) return tree0; else if ( treeNum == 1 ) return tree1; else if ( treeNum == 2 ) return tree2; else if ( treeNum == 3 ) return tree3; return null; } // build a string public String toString() { } }
Complete the toString()
method. (Copy and paste will be useful.)