Lab 10: A Registration System

Copyright RIT 2006
$Id: writeup.xml,v 1.0 2006/11/01 15:42:00 vcss231 Exp vcss231 $


Goal

Term 20092: This lab is to be submitted by the end of the day, Sunday Feb. 21st. This applies to all sections of the course!

In this lab you will perform software maintenance on a course registration program. Software maintenance, as you learned, is the last phase of the Software Life Cycle and involves finding and fixing bugs or system deficiencies addressed in problem reports, adding new features (enhancements), and updating code as needed for business or product changes (requirements changes). In this lab, you will do all 3 forms of maintenance. You will discover that modifying and debugging another person's code is not always fun or easy.

This lab will be done in teams of two students each. Your instructor will form the teams for this lab and will tell you which team you are on when you arrive for lab.

As you finish each activity, be sure your team carefully tests your code changes. You will make only one submission for all the maintenance activities in this lab.


Team Setup

You are to work on this lab in teams of size 2. Students who do not abide by this rule will not get full points for in-class participation.

Overview

Objectives

Ask Dr. Tiger

Pre - Lab Work

  1. Review your class notes for the preceeding week.

In-Lab Activities

Activity #1 : Read the Program Requirements

  1. This software is a course registration system.
  2. The educational institution provides a list of available courses which are hard-coded into the software. The software assigns course numbers to the courses.
  3. The user enters the names of all students who want to register for the available courses. The system assigns a registration ID to every student.
  4. The software processes a list of events; an event occurs whenever a student registers or withdraws from a course. To register or withdraw from a course, students must provide their registration ID and the course number.
  5. Every course has a maximum capacity, and the student can register only if the number of currently registered students is less than the capacity.
  6. Students are allowed to register for only a limited number of courses. Students cannot register for a course if already registered in the same course (can't register for the same course twice), or if the student has already registered for the maximum number of courses.
  7. A student can withdraw from a course only if already registered for that course.
  8. At the end of the registration, the program outputs, for every course, the list of students registered for that course. Moreover, for every student it outputs the course registration list for each student.
  9. As with previous labs this quarter, you do not need to worry about error checking, for example if a string is entered where a number is expected).

Activity #2 : Understand the Program Specifications

Input

A sample data file can be found here (/~vcss231/pub/lab10/Binaries/input1.txt) .

Output

The program outputs prompts for the above input. After the registration ends (i.e. all input has been read), the program outputs, for every course, the list of registered students (in the order in which they registered). Similarly, for every student the program outputs the list of courses the student has registered for (in the order in which the student registered for these courses).

We have provided you with a sample run of the registration. Click here (/~vcss231/pub/lab10/Binaries/input1.txt) to see the input file that produced this output (/~vcss231/pub/lab10/Binaries/output1.txt) This output was produced by redirecting the given input file to the standard input.

Activity #3 : Study the Program Design

The registration system consists of 3 classes: Registration, Course, and Student. The UML diagram class diagram below shows each of the classes and the relationships in this program.


Registration System Classes and Collaborations

The Registration class is the main class which handles the interface with the user. It is responsible for reading and interpreting the user's input and recording appropriate actions. The class defines a constant array with all the course names, and it stores two arrays, one of objects from the class Student, and the other of objects from the class Course. The index of a course in course array is exactly 1 less than the corresponding course number, similarly the index of a student in the student array is one less than her/his registration ID. The registration class handles all the requests by calling "registerStudent" or "withdrawStudent" methods on the specified object from the class Course.

A brief description of the remaining classes is given below:

Activity #4 : Review the Maintenance Issues

The Hogwarts School of Witchcraft and Wizardry is currently using the software to register their students for Potions, Transfiguration, and Charms. However, recent changes in the Ministry of Magic regulations call for the following changes:

1. Requirements Change:

Until now, the maximum number of students in each course was set to 3. However, now there can be up to 6 students in Charms, not more than 4 students in Potions, and maximum of 5 students in Transfiguration.

2. System Enhancement:

In addition to printing the lists of students in each course, the regulations now require, for every course, to clearly state the number of registered students and the maximum allowed capacity of the course.

3. System Defect:

Students have been complaining that sometimes their course lists do not seem correct if they attempt to withdraw from a course. No other documentation is available.

Activity #5 : Get the files you need to complete this lab

The files that you need to complete this lab are contained in the jar file located here (/~vcss231/pub/lab10/Binaries/lab10.jar) . Download the jar file and unpack it in an appropriate location in your account.

DO NOT attempt to change any code until you understand what the registration program does, the design of the program, and the output that it produces. Modifying code before understanding the program will simply be a waste of your time, and may introduce additional errors!

The lab10.jar file contains the code that implements the registration system. You should find three files in this directory: Registration.java, Course.java, and Student.java.

We have only provided you with one sample data file, /~vcss231/pub/lab10/Binaries/input1.txt. It will be up to your group to determine the test cases for your code, i.e. to develop your own test data files.

As you complete each portion of this lab, make a copy of it and store it in directories Task1, Task2, and Task3. This will give you an easy way to "fall back" if you find you have introduced bugs in later activities.

Make sure you run the registration using the test data shown above so that you get a feel for what the program is doing.

Do not proceed to the next step in this lab until you understand what the program is doing and how it works with the data in the input files.

When modifying a source code, it is a good practice to put a comment in front of every line that has been changed, along with an identifier (such as initials) of the person who changed the line, the date of the change, and a brief description of the nature of the change. An example of such a comment is the first comment within the main method in the Registration class. Include such comments with every modification you make.

Activity #6 : Maintenance Task 1. Modify the code to meet the requirement change

Requirements Change

Make the requirements change to reflect the new maximum course capacities. After completing your coding changes, test your solution to be sure it works properly. Do not go on to the next activity until you are sure your changes are correct.

Make sure that you take advantage of features in the language that might make a similar change in the requirements easier to make in the future. The constants 4, 5, and 6 should appear only once in all your code (including all three classes).

Remember that any changes you make to the code must be documented. Your documentation should state the changes that were made, and why they were made. Note that as soon as you change any code, you have become a contributor to the program.

When you have made the necessary changes to the program, very carefully test your code. Then copy the working version into the directory Task1 for safekeeping. Do not continue with the next activity until you are sure your code works properly.

Activity #7 : Maintenance Task 2. Implement the system enhancement

Make the enhancement to report the number of registered students and the capacity of every course.

Replace the output statement "These students currently registered for this course." with the following print statement.


System.out.println( registered-students + 
		    " students are currently registered, the capacity is " + 
		    capacity + "." );
      

Of course, substitute your own variable names for registered-students and capacity.

Your programs will be tested using a system that requires the output from your program to match the output from the solution exactly. When you decide where the print statement should be located, you can use cut and paste to insert the sample print statement into the correct location in the program.

Click here (/~vcss231/pub/lab10/Binaries/output1b.txt) to see a sample of what your output should look like after adding this enhancement.

Don't proceed to the next activity until you are sure that the enhancement is working correctly. When you are sure that the changes you have made are correct, copy the working version of your code for this activity into the Task2 directory and then continue with the next activity.

Activity #8 : Maintenance Task 3. Correct the system defect

System Defect

Address the problem report that indicates that after successfully withdrawing from a course, the students sometimes still see the course listed on their transcripts.

To correct this problem, start by building some test inputs to test the basic behavior of the registration system. First, try simple inputs that test the registration and withdrawal requests. If you don't find any errors with these test cases, try building more complex cases. For example, what happens when somebody withdraws from a course they did not register for? Or, what happens when a student attempts to register for a full course, then somebody withdraws and then the first student tries to register again?

As you can see, this simple program produces a very large number of test cases and each one is critical to ensuring quality!

However, since it's the end of the quarter (whew), here are two hints that should help: Check the basics. It's a single problem.

How To Submit

When you have addressed this problem, submit your code using the following command:


try grd-231 lab10-1 Registration.java Course.java Student.java
        


Grade Computation

Grade Breakdown: