Ok, here are a couple of ideas that I hope would helpAnd do the check before you growBranchCode:public class Branch implements Comparable<Branch> { public int compareTo ( Branch o ) { //Do the comparison to check for height and direction }
Code:public void growBranch ( Branch b ) throws Exception { Iterator<Branch> it = branches.iterator() ; while ( it.hasNext() ) { if ( it.next().compareTo( b ) == 0 ) { throw new Exception() ; } } branches.add( b ) ; }




Reply With Quote