Source of Student.java


  1: /**
  2:    A class that represents a student that can be cloned.
  3:    
  4:    @author Frank M. Carrano
  5:    @author Timothy M. Henry
  6:    @version 5.0
  7: */
  8: public class Student implements Cloneable
  9: {
 10:         private Name   fullName;
 11:         private String id;      // Identification number

 13: /* Constructors and the methods setStudent, setName, setId,
 14:         getName, getId, and toString go here. 
 15:    . . . */
 16:    
 17:         public Object clone()
 18:         {
 19:       Student theCopy = null;

 21:       try
 22:       {
 23:          theCopy = (Student)super.clone(); // Object can throw an exception
 24:       }
 25:       catch (CloneNotSupportedException e)
 26:       {
 27:          throw new Error(e.toString());
 28:       }

 30:       theCopy.fullName = (Name)fullName.clone();
 31:       return theCopy;
 32:         } // end clone
 33: }  // end Student