import java.util.*; class Child implements AncTree { String name; int yob; // year-of-birth String eye; // eye-color, e.g. "brown" AncTree ma, pa; // mother, father /** 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; } public int size( /* Child this */ ) { return 1 + (this.ma).size() + (this.pa).size(); } public AncTree changeName( /* Child this, */ String name1, String name2 ) { return new Child( ( this.name.equals(name1) ? name2 : this.name ), this.yob, this.eye, (this.ma).changeName(name1,name2), (this.pa).changeName(name1,name2) ); } public List allNames( /* AncTree this */ ) { List result = new ArrayList(); result.addAll( this.ma.allNames() ); result.add( this.name ); result.addAll( this.pa.allNames() ); return result; } /** @Override */ public String toString( /* Child this */ ) { return "new Child" + "( " + "\"" + this.name.toString() + "\"" + ", " + this.yob + ", " + "\"" + this.eye.toString() + "\"" + ", " + this.ma.toString() + ", " + this.pa.toString() + " )"; } }