There is only one minor change to be made to the Course class from the way that it was presented in Chapter 14, to accommodate our new file persistence scheme.
Because we're now reading in a predetermined section number from the SoC_SP2004.dat file, we must modify the ScheduleSection method of the Course class so that it no longer automatically assigns a "one-up" section number to each Section.
Here is the original code for the ScheduleSection method from Chapter 14; the highlighted code shows that we were automatically determining how many sections had already been created and stored in the offeredAsSection collection (an attribute of Course), and bumping that up by one to create a section number on the fly.
public Section ScheduleSection(char day, string time, string room, int capacity) { // Create a new Section (note the creative way in // which we are assigning a section number) ... Section s = new Section(offeredAsSection.Count + 1, day, time, this, room, capacity); // ... and then remember it! offeredAsSection.Add(s); return s; }
In our new, modified version of this method, shown in the following code, we've added an argument, secNo, to enable us to simply hand in the section number as read in from the data file.