You are now able to produce a report that sorts course sessions by their department. You will now enhance the report code to sort sessions by both department and number. You will need to first modify the test to incorporate appropriate data. The following test (in CourseReportTest) adds two new sessions. The test data now includes two sessions that share the same department. package sis.report; import junit.framework.*; import java.util.*; import sis.studentinfo.*; import static sis.report.ReportConstant.NEWLINE; public class CourseReportTest extends TestCase { public void testReport() { final Date date = new Date(); CourseReport report = new CourseReport(); report.add(CourseSession.create("ENGL", "101", date)); report.add(CourseSession.create("CZEC", "200", date)); report.add(CourseSession.create("ITAL", "410", date)); report.add(CourseSession.create("CZEC", "220", date)); report.add(CourseSession.create("ITAL", "330", date)); assertEquals( "CZEC 200" + NEWLINE + "CZEC 220" + NEWLINE + "ENGL 101" + NEWLINE + "ITAL 330" + NEWLINE + "ITAL 410" + NEWLINE, report.text()); } } In order to determine the proper ordering of these students, your compareTo method will need to first look at department. If the departments are different, that comparison will be sufficient to provide a return value. If the departments are the same, you will have to compare the course numbers. |