/** * Holds data obtained from Banner about a particular course a student has taken. When initially * returned from the transcript parser, the courseId will hold the typical Dowling course format * (for example, "CSC175"). This must subsequently be translated before it is passed into * the processor system. */ public class Course { private String courseId; // id from our db. private String discipline; private String courseNumber; private char courseLetter; private int credits; private String grade; /** * Constructs a Course object. */ public Course() { } /** * Retrieves the associated course id as stored in the local database. * @return A String representing the course id. -1 if unrecognized course. */ public String getCourseId() { return courseId; } /** * Retrieves the associated discipline. * @return A String representing the discipline. */ public String getDiscipline() { return discipline; } /** * Retrieves the associated course number. * @return A String representing the course number. */ public String getCourseNumber() { return courseNumber; } /** * Retrieves the associated dowling course code. * @return A String representing the dowling course code. */ public String getDowlingCourseCode() { String out = discipline + " " + courseNumber; if(courseLetter != 0) out += courseLetter; return out; } /** * Retrieves the associated credits hours earned. * @return An int representing the number of credits hours earned. */ public int getCreditHours() { return credits; } /** * Retrieves the associated course letter. * @return A char representing the course letter. */ public char getCourseLetter() { return courseLetter; } /** * Retrieves the associated grade. * @return A String representing the grade. It will be that parsed * directly from the transcript, for example A+, W, F, T, and so on. */ public String getGrade() { return grade; } /** * Sets the courseId for this course. Used to set the translated courseId. * @param courseId The string to store as the courseId. */ public void setCourseId(String courseId) { this.courseId = courseId; } /** * Sets the discipline portion of the courseId. Used prior to translating * the courseId. * @param subject The subject of the course. */ public void setDiscipline(String subject) { discipline = subject; } /** * Sets the course number porition of the courseId and splits off the course * letter. Used to set the course number prior to translating the courseId. * @param cn The course code of the course. */ public void setCourseNumber(String cn) { if(cn.length() < 3) { throw new RuntimeException( courseNumber + " is a malformed course number."); } courseLetter = cn.charAt(cn.length()-1); if(!Character.isLetter(courseLetter)) { courseLetter = 0; courseNumber = cn; } else courseNumber = cn.substring(0, cn.length()-1); } /* { if(courseNum.length() < 3) throw new RuntimeException("Course " + courseNum + " was invalid"); else if(courseNum.length() == 3) { courseLetter = 0; dowlingNum += " " + courseNum; } else { courseLetter = courseNum.charAt(courseNum.length()-1); dowlingNum += " " + courseNum; if(!Character.isLetter(courseLetter)) throw new RuntimeException("Course " + courseNum + " was invalid"); } }*/ /** * Sets the credit hours (credits) obtained in taking the course. * @param creditHours Number of credit hours for this course. */ public void setCreditHours(String creditHours) { credits = (int) Double.parseDouble(creditHours); } /** * Sets the grade obtained in taking the course. * @param grd The letter grade earned in the particular course. */ public void setGrade(String grd) { grade = grd; } /** * Prints out a string representation of the class fields. * @return A String representation of the instance. */ public String toString() { StringBuffer strBuff = new StringBuffer(); strBuff.append("DowlingId=").append(getDowlingCourseCode()).append(" "); strBuff.append("CourseId=").append(courseId).append(" "); strBuff.append("Credits=").append(credits).append(" "); strBuff.append("Letter=").append(courseLetter).append(" "); strBuff.append("Grade=").append(grade); return strBuff.toString(); } }