Home > Articles > Programming > Java

  • Print
  • + Share This
This chapter is from the book

Enrolling Students

Story Icon

Courses don't earn any revenue for the school unless students enroll in them. Much of the student information system will require you to be able to work with more than one student at a time. You will want to store groups, or collections, of students and later execute operations against the students in these collections.

CourseSession will need to store a new attribute—a collection of Student objects. You will want to bolster your CourseSession creation test so that it says something about this new attribute. If you have just created a new course session, you haven't yet enrolled any students in it. What can you assert against an empty course session?

Modify testCreate so that it contains the bolded assertion:

public void testCreate() {
   CourseSession session = new CourseSession("ENGL", "101");
   assertEquals("ENGL", session.getDepartment());
   assertEquals("101", session.getNumber());
   assertEquals(0, session.getNumberOfStudents());
}
  • + Share This
  • 🔖 Save To Your Account