Commit ce57dcf8 by Paktalin

Small refactoring in Lesson 6

parent d478a696
......@@ -34,16 +34,16 @@ public abstract class Session implements Comparable<Session>{
return this.getNumber().compareTo(that.getNumber());
}
protected void setNumberOfCredits(int numberOfCredits) {
void setNumberOfCredits(int numberOfCredits) {
this.numberOfCredits = numberOfCredits;
}
public void enroll(Student student) {
void enroll(Student student) {
students.add(student);
student.addCredits(numberOfCredits);
}
public Date getEndDate() {
Date getEndDate() {
GregorianCalendar calendar = new GregorianCalendar();
calendar.setTime(getStartDate());
calendar.add(Calendar.DAY_OF_YEAR, getNumberOfDaysInSession());
......@@ -56,7 +56,7 @@ public abstract class Session implements Comparable<Session>{
return getSessionLength() * daysInWeek - daysFromFridayToMonday;
}
public List<Student> getAllStudents() {
List<Student> getAllStudents() {
return students;
}
......@@ -68,10 +68,10 @@ public abstract class Session implements Comparable<Session>{
int getNumberOfStudents() {
return students.size();
}
public String getDepartment() {
String getDepartment() {
return department;
}
public String getNumber() {
String getNumber() {
return number;
}
Student get(int index) {
......
......@@ -36,4 +36,4 @@ public class SummerCourseSession extends Session {
protected int getSessionLength() {
return 8;
}
}
}
\ No newline at end of file
......@@ -22,7 +22,7 @@ public class CourseSessionTest extends SessionTest {
}
@Override
protected Date calculateEndDate() {
protected Date getExpectedEndDate() {
return DateUtil.createDate(2003, 4, 25);
}
}
......@@ -22,6 +22,7 @@ abstract public class SessionTest extends TestCase {
}
protected abstract Session createSession(String department, String number, Date startDate);
protected abstract Date getExpectedEndDate();
public void testCreate() {
assertEquals("ENGL", session.getDepartment());
......@@ -62,8 +63,6 @@ abstract public class SessionTest extends TestCase {
public void testCourseDates() {
Date startDate = DateUtil.createDate(2003, 1, 6);
Session session = createSession("ENGL", "200", startDate);
assertEquals(calculateEndDate(), session.getEndDate());
assertEquals(getExpectedEndDate(), session.getEndDate());
}
protected abstract Date calculateEndDate();
}
......@@ -24,7 +24,7 @@ public class SummerCourseSessionTest extends SessionTest {
}
@Override
protected Date calculateEndDate() {
protected Date getExpectedEndDate() {
return DateUtil.createDate(2003, 2, 28);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment