CSCI 1301 - Lab 16

Clément Aubert

March 6, 2018

Part 0 - Wrapping Up

The code we just studied in class, slightly expanded and with an application program, is available to download.

Part I - Milestone #2

You accomplished a lot since Milestone #1 (that was presented in Lab 07), so let’s take a moment to look back at what you learned.

What You Learned

To Get Better at Using Softwares

To Design, Edit and Enhance Classes

To Use Classes

Various

To Write Branching Programs

To Solve Problems!

Did You Pushed Further?

Part II - Working on Problem-Solving

Download, extract, compile and execute Course.zip. Then, read the code, and make sure you understand everything in it: the role of the static attribute, the difference between the two constructors, the branching in the constructor that takes two arguments. Then, do the following:

  1. Write a ToString method that returns
    1. The name of the student, followed by
    2. “is registered for section A.” of the student is in section A, “is on the waiting list.” if the student is on the waiting list.
  2. Test your method in the program, printing the information about various students.
  3. Your next step will be to open a second section:
    1. We want to have a section B, with 4 seats available. Implement the existence of this section with a static attribute.
    2. The constructor that takes one argument should now assign the student to section A if there is room available, to section B if section A is full but section B isn’t, or to the waiting list if both sections are full.
    3. Think about how you should change the constructor that takes two arguments, and implement what seems to be logical. For instance, if a student wants to enroll in section B, but section B is full and section A isn’t, should the student go to section A or be on the waiting list?
    4. Finally, correct your ToString method, so that the string returned describes accurately the section the student is enrolled in.

Bonus: There is an inconsistency in the constructor that takes two arguments, can you spot it? What will happen if the user gave a code for the section that isn’t 'A' or 'a', and section A is full? Can you fix this?