001 package ttsolver.model;
002
003 import ifs.util.FastVector;
004
005 import java.util.Vector;
006
007 /**
008 * Cross-listed lectures of a lecture.
009 * <br><br>
010 * This is used only when the model is loaded directly from the database. One class can have several
011 * identifications there.
012 *
013 * @author <a href="mailto:muller@ktiml.mff.cuni.cz">Tomáš Müller</a>
014 * @version 1.0
015 */
016
017 public class CrossListedLecture {
018 private String iSubject;
019 private String iCourseNbr;
020 private String iIType;
021 private int iSection;
022 private String iName;
023
024 private Lecture iLecture = null;;
025 private Vector iStudents = new FastVector(1);
026
027 /** Constructor
028 * @param subject subject
029 * @param courseNbr course number
030 * @param iType instructional type
031 * @param section section
032 */
033 public CrossListedLecture(String subject, String courseNbr, String iType, int section) {
034 this(subject,courseNbr,iType,section,subject+" "+courseNbr+" "+iType+" "+section);
035 }
036
037 /** Constructor
038 * @param subject subject
039 * @param courseNbr course number
040 * @param iType instructional type
041 * @param section section
042 * @param name (string representation of this class)
043 */
044 public CrossListedLecture(String subject, String courseNbr, String iType, int section, String name) {
045 iSubject = subject;
046 iCourseNbr = courseNbr;
047 iIType = iType;
048 iSection = section;
049 iName = name;
050 }
051
052 /** Subject */
053 public String getSubject() { return iSubject; }
054 /** Course number */
055 public String getCourseNbr() { return iCourseNbr; }
056 /** Instructional type */
057 public String getIType() { return iIType; }
058 /** Section */
059 public int getSection() { return iSection; }
060 /** Name */
061 public String getName() { return iName; }
062
063 /** Parent lecture */
064 public Lecture getLecture() { return iLecture; }
065 /** Parent lecture */
066 public void setLecture(Lecture lecture) { iLecture = lecture; }
067
068 /** List of enrolled students */
069 public Vector students() { return iStudents; }
070 /** Add student enrollment */
071 public void addStudent(String student) {
072 iStudents.addElement(student);
073 iLecture.addSameLectureStudent(student);
074 }
075 /** Has given student enrollment */
076 public boolean hasStudent(String student) { return iStudents.contains(student);}
077
078 public boolean equals(Object o) {
079 if (o==null || !(o instanceof CrossListedLecture)) return false;
080 CrossListedLecture sl = (CrossListedLecture)o;
081 return (getSubject().equals(sl.getSubject()) &&
082 getCourseNbr().equals(sl.getCourseNbr()) &&
083 getIType().equals(sl.getIType()) &&
084 getSection() == sl.getSection());
085 }
086 }