CS368 p2

Programming Assignment p2 : Linked List Student Database

DUE by 8:00 PM on Thursday, March 27th
p2 Announcements | Overview | Specifications | Submission

p2 Announcements

Corrections, clarifications, and other announcements regarding this programming assignment will be found below.

  • If you are not familiar with linked lists, please check out this reading on linked lists.
  • It is often difficult when programming with pointers to locate errors. We encourage you to start early and test your program often.
  • Completing Programming Assignment p2 is required for Programming Assignment p3, which extends the work you will do on this program.

Overview

For this assignment you will modify the database you developed in Programming Assignment p1 by keeping the students in a linked list ordered by student ID. You'll also make your code more object-oriented by using C++ classes for the ordered linked list and to represent the student information stored in the list.

Goals

The goals of this assignment are to gain experience:

  • manipulating pointers
  • allocating and deallocating memory using new and delete
  • defining and using C++ classes
  • writing classes to fit a given specification

Specifications

For this assignment you will complete the implementation files (i.e., the source files) for two classes for which we've provided the interface files (i.e., the header files). We've also provided an object file for the main program that uses the classes that you implement and has the same commands as used in Programming Assignment p1.

The Student Class

The Student class is used to represent individual students that you represented as structs in Programming Assignment p1. Each Student object will again contain a student ID, the total number of credits, and the student's overall GPA. The header file containing the interface for the Student class is given in Student.h. You can copy this file from this location:

~cs368-1/public/html/assignments/p2/files/Student.h

Complete the Student class by writing all of the member functions as described in the header file.

The SortedList Class

The SortedList class is used to implement an ordered singly-linked list of students. The list is ordered by student ID from smallest to largest. The header file containing the interface for the SortedList class is given in SortedList.h. You can copy this file from this location:

~cs368-1/public/html/assignments/p2/files/SortedList.h

Complete the SortedList class by writing all of the member functions as described in the header file.

User Interface

We have provided you with the code for the main program, which you must make work with your code. You can copy the main program containing the user interface from this location:

~cs368-1/public/html/assignments/p2/files/studentDB.o

The user interface has already been compiled into object code. Since C++ object code is platform-dependent (unlike Java bytecode, which is platform-independent), the precompiled file of the user interface requires you to do your work on the mumble Linux machines.

In order to create an executable for your program, you'll need to link the user interface object code with the object code for your classes. The following Linux commands show how this can is done:

g++ -c Student.cpp
g++ -c SortedList.cpp
g++ Student.o SortedList.o studentDB.o -o runDB

The first two commands compile the source files that you've implemented. The third command links the object files for this program and creates an executable named runDB.

The commands that our user interface accepts are the same as those for Programming Assignment p1 plus an additional "help" command:

  • a ID credits GPA
    add a student to the database
  • d ID
    delete a student from the database
  • u ID grade N
    update a student's record to include a grade for a course
  • p
    print the database
  • q
    quit the program
  • ?
    print out help on the commands

Error and Bounds Checking

All error checking and bounds checking is done in the user interface object code given to you. You do not need to add any. In particular, you may assume that all values passed to constructors or functions are valid and have the appropriate range as described in Programming Assignment p1.

Submitting Your Work

Make sure your code follows the style and commenting standards used in CS 302 and CS 367. Note: the commenting standards use javadoc comments for class, method, and constructor headers. You do not need to use javadoc comments in your c++ programs for CS 368; however, your comments should include the same information as the javadoc comments. For example, your function header comments should include a description of what the function does, the name and a short description of each parameter, and a description of the return value.

Electronically submit the following file to your in "handin" directory by the due date and time (late policy):

  • Student.cpp containing your source code for the Student class, and
  • SortedList.cpp containing your source code for the SortedList class.

  • If you are working with a partner, only one partner submits the program files, but both partners must submit to his/her own hand-in directory a completed README.txt file. Students working in pairs must follow the rules for pair programming.

Please turn in only the files named above. Extra files clutter up the "handin" directories.

© 2012-2013 CS368 Instructors