public class Student implements Cloneable
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 4.0
7: */
8: public class Student implements Cloneable
9: {
10: private Name fullName;
11: private String id; // Identification number
12: /* < Constructors and the methods setStudent, setName, setId,
13: getName, getId, and toString go here.
14: . . . > */
15:
16: public Object clone()
17: {
18: Student theCopy = null;
19: try
20: {
21: theCopy = (Student)super.clone(); // Object can throw an exception
22: }
23: catch (CloneNotSupportedException e)
24: {
25: throw new Error(e.toString());
26: }
27: theCopy.fullName = (Name)fullName.clone();
28: return theCopy;
29: } // end clone
30: } // end Student