Source of Neighbor.java


  1: 
  2: public class Neighbor implements Cloneable
  3: {
  4:     private String name;
  5:     private int numberOfChildren;
  6:     private PetRecord pet;
  7: 
  8:     public Object clone( )
  9:     {
 10:         try
 11:         {
 12:             Neighbor copy = (Neighbor)super.clone( );
 13:             copy.pet = (PetRecord)pet.clone( );
 14:             return copy;
 15:         }
 16:         catch(CloneNotSupportedException e)
 17:         {//This should not happen
 18:             return null; //To keep the compiler happy.
 19:         }
 20:     }
 21: 
 22:     public PetRecord getPet( )
 23:     {
 24:         return (PetRecord)pet.clone( );
 25:     }
 26: 
 27:             //<There are presumably other methods that are not shown.>
 28: }