
public class Neighbor implements Cloneable
{
    private String name;
    private int numberOfChildren;
    private PetRecord pet;

    public Object clone( )
    {
        try
        {
            Neighbor copy = (Neighbor)super.clone( );
            copy.pet = (PetRecord)pet.clone( );
            return copy;
        }
        catch(CloneNotSupportedException e)
        {//This should not happen
            return null; //To keep the compiler happy.
        }
    }

    public PetRecord getPet( )
    {
        return (PetRecord)pet.clone( );
    }

            //<There are presumably other methods that are not shown.>
}
