UMBC, CMSC202 Computer Science II, Spring 2007

Project 1: Hockey Ratings

Due: Sunday, February 25, 2007, 11:59pm + 59 seconds


The objective of this project is to practice working with the mechanics of C++ classes.


Hockey players are often rated by a simple plus-minus rating. If their team scores a goal when the player is on the ice, their rating is increased by 1. If the opposing team scores a goal, then their rating is decreased by 1. Negative ratings indicate a poor player. The plus-minus rating is preferred over points for goals and assists because it recognizes that the contribution of defensemen is not in scoring goals. For this project, you will implement a program that reads in the players' statistics, stores them in the players' records and stores the records themselves in a priority queue. The priority queue will allow the coach to pick a player with the highest plus-minus rating.


Project 0: Due Friday, February 16, 2007

As stated in the course project policy, Project 0 is a required part of the course. You must complete the following tasks by midnight Friday, February 16.

  1. Copy to your own directory the following file in the GL file system: /afs/

  2. Add a comment of your own choosing to the bottom of the file using a text editor of your choice.

  3. Submit the modified file to Project 0: submit cs202 proj0 secrets
This shows that the system has been configured to accept submissions from your GL account.

Project 1: Due Sunday, February 25, 2007

You are given the header files of two C++ classes: Stat and Player: stat.h, player.h. You must work with these files as given and not change them in anyway. The Stat class is mostly a data class --- there is an overloaded < operator to allow for comparisons. The Stat class has just two data members: game and pmRating. The game member holds the game number of a particular game. The pmRating member holds the plus-minus rating of a player in that game.

The Player class is more complicated. Since Player has dynamically allocated data members, several member functions have been implemented already, including the default constructor, the destructor and the assignment operator. (You will find out more about these later this semester). The implementations of these functions are in player.cpp.

Player contains a vector of Stat records --- one for each game that the player has played in. The medianRating member contains the median plus-minus rating of the player in the games he/she played in.

Part 1 of your assignment is to implement the following 3 member functions in Player:

Another member function called debug() exists to allow you to have access to private data members for debugging purposes. You should not use debug() in your final submission.

Part 2 of your assignment is to write a main program that reads in the data for each player. For this project, we will use UNIX input redirection to supply the input to the program. So, your program should read from the standard input. Each player's record must then be inserted into a priority queue, where the priority is determined by the player's median plus-minus rating.

The priority queue data structure will maintain its items so that the item with the highest priority is at the "top". If the top item is popped off (i.e., removed), the priority queue adjusts itself so that the item with the next highest priority is on top. You will be using the priority queue class from the Standard Template Library (STL). Details are below.

The main program must then remove the top 5 players from the priority queue and print out their statistics using PrintAll(). Finally, the program removes the rest of the players from the priority queue (in medianRating order) and prints out their names and median rating using Print().

Part 3 of your project is to create an input file that thoroughly tests your program. Although your program does not have to deal with improperly formatted input, you must still check that your program works with "weird" but properly formatted input. Both sample input files given to you are relatively nice. It is your responsibility as the programmer to construct these "weird" test cases. Your grade for this part of the project depends the "weirdness" of the input file you construct.

Implementation Notes


Depending on your project design, the following hints might be useful, or not.


Turning in your program

Use the UNIX submit command to turn in your project. You should submit 4 files:
  1. myplayer.cpp must contain the implementation of the remaining member functions in player.h
  2. proj1.cpp must contain the main function that completes Part 2 of the project.
  3. myinput.txt must be a test input file that you created to show that you have fully exercised your program.
  4. myoutput.txt must be the output of your program given myinput.txt.

Do not submit any of the files that were given to you: stat.h, player.h and player.cpp. Since you are not allowed to change these files, your program should compile and run correctly with the original versions of these files.

When you are done, use the class name 'cs202' and the project name 'proj1' to submit your project. The UNIX command to do this should look like:

submit cs202 proj1 myplayer.cpp proj1.cpp myinput.txt myoutput.txt Longer documentation of the submit system can be found here.

[CSEE] | [CMSC202] | [Spring '07 CMSC202]             Last Modified: 11 Feb 2007 13:37:32 EST