KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > cache > data > Student


1 package org.jboss.cache.data;
2
3 import java.util.*;
4
5
6 /**
7  * @author Ben Wang
8  */

9 public class Student extends Person
10 {
11    protected String JavaDoc school;
12 // protected Set courses = new LinkedHashSet();
13
protected List courses = new ArrayList();
14
15    public void setSchool(String JavaDoc school)
16    {
17       this.school = school;
18    }
19
20    public String JavaDoc 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 JavaDoc toString()
41    {
42       StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
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