1 package org.jboss.cache.data; 2 3 import java.util.*; 4 5 6 9 public class Student extends Person 10 { 11 protected String school; 12 protected List courses = new ArrayList(); 14 15 public void setSchool(String school) 16 { 17 this.school = school; 18 } 19 20 public String getSchool() 21 { 22 return this.school; 23 } 24 25 public void addCourse(Course course) 26 { 27 courses.add(course); 28 } 29 30 public void removeCourse(Course course) 31 { 32 courses.remove(course); 33 } 34 35 public Collection getCourses() 36 { 37 return Collections.unmodifiableList(courses); 38 } 39 40 public String toString() 41 { 42 StringBuffer buf = new StringBuffer (); 43 buf.append("{Name = " +name).append(", School = " +school); 44 if (address != null) 45 buf.append(", Address = " + address.getSimpleAddress()); 46 buf.append("}\n"); 47 buf.append("Courses:\n"); 48 for (Iterator iter = getCourses().iterator(); iter.hasNext(); ) 49 buf.append(iter.next()); 50 51 return buf.toString(); 52 } 53 54 } 55 | Popular Tags |