package org.jboss.cache.data;

import java.util.*;


/**
 * @author Ben Wang
 */
public class Student extends Person
{
   protected String school;
//   protected Set   courses = new LinkedHashSet();
   protected List   courses = new ArrayList();

   public void setSchool(String school)
   {
      this.school = school;
   }

   public String getSchool()
   {
      return this.school;
   }

   public void addCourse(Course course)
   {
      courses.add(course);
   }

   public void removeCourse(Course course)
   {
      courses.remove(course);
   }

   public Collection getCourses()
   {
      return Collections.unmodifiableList(courses);
   }

   public String toString()
   {
      StringBuffer buf = new StringBuffer();
      buf.append("{Name = " +name).append(", School = " +school);
      if (address != null)
         buf.append(", Address = " + address.getSimpleAddress());
      buf.append("}\n");
      buf.append("Courses:\n");
      for (Iterator iter = getCourses().iterator(); iter.hasNext(); )
         buf.append(iter.next());

      return buf.toString();
   }

}
