import java.util.*; class Child extends AncTree { String name; int yob; // year-of-birth String eye; // eye-color, e.g. "brown" AncTree ma, pa; // mother, father private List cachedResult = null; /** standard constructor */ public Child( String _name, int _yob, String _eye, AncTree _ma, AncTree _pa ) { this.name = _name; this.yob = _yob; this.eye = _eye; this.ma = _ma; this.pa = _pa; } int size( /* Child this */ ) { return 1 + this.ma.size() + this.pa.size(); } List allNames( /* AncTree this */ ) { if (cachedResult == null) { List result = new ArrayList(); result.addAll( this.ma.allNames() ); result.add( this.name ); result.addAll( this.pa.allNames() ); cachedResult = Collections.unmodifiableList(result); } return cachedResult; } /** @Override */ public String toString( /* Child this */ ) { return "new Child" + "( " + this.name.toString() + ", " + this.yob + ", " + this.eye.toString() + ", " + this.ma.toString() + ", " + this.pa.toString() + " )"; } }