Summer Course Sessions


The CourseSession class currently supports only 15-week sessions (with a one-week break) that occur in the spring and fall. The university also needs support for summer sessions. Summer sessions will begin in early June. They last eight weeks with no break.


One solution would be to pass the session length into the CourseSession class, store it, and use it as a multiplier when calculating the session end date.

However, there are many other differences between summer sessions and spring/fall sessions, including differences in maximum class session, credit values, and so on. For this reason, you have chosen to create a new class named SummerCourseSession.

The simplest approach for implementing SummerCourseSession, given what you know, is to have it extend from CourseSession. A SummerCourseSession is a CourseSession with some refinement on the details (see Figure 6.2).

Figure 6.2. SummerCourseSession Specialization


You want to create the SummerCourseSession classes (test and production) in a new package, summer, for organizational purposes.

The test you initially code verifies that SummerCourseSession calculates the course end date correctly:

 package sis.summer; import junit.framework.*; import java.util.*; import sis.studentinfo.*; public class SummerCourseSessionTest extends TestCase {    public void testEndDate() {       Date startDate = DateUtil.createDate(2003, 6, 9);       CourseSession session =          SummerCourseSession.create("ENGL", "200", startDate);       Date eightWeeksOut = DateUtil.createDate(2003, 8, 1);       assertEquals(eightWeeksOut, session.getEndDate());    } } 



Agile Java. Crafting Code with Test-Driven Development
Agile Javaв„ў: Crafting Code with Test-Driven Development
ISBN: 0131482394
EAN: 2147483647
Year: 2003
Pages: 391
Authors: Jeff Langr

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net