YALE UNIVERSITY
DEPARTMENT OF COMPUTER SCIENCE
CPSC 427: Object-Oriented Programming | Handout #4 | |
Professor M. J. Fischer | February 22, 2016 | |
Problem Set 3
Due before midnight on Monday, March 7, 2016.
This assignment is to complete the skater ranking program begun in assignment 2 by computing the final placement of the skaters according to the 6.0 judging system.
Here’s an overview of the steps the program should take once the data has been read in from the file:
The program design problem in this assignment is to organize the data in ways that facilitate each of these steps. A simpler organization of the data into just two classes SixOh and Score was adequate for assignment 2.
For this assignment, you must change the data organization according to the following.1
Here are some more details for how to compute each of the steps above.
The ordinals are computed separately for each judge, using the myScores list of score pointers described above. The method is to sort myScores in decreasing order of the mark field in each Score object. This will require that you use the 3-argument version of sort, where the 3rd argument is a comparison function that must return true if the first mark is strictly better than the second and false otherwise. You should make this comparison function a private static function in class Judge.
Once the marks have been sorted, the ordinals are assigned in decreasing order of marks. In case a judge gives the same mark to two different skaters, both skaters should be assigned the same ordinal, and the next ordinal should be skipped. More generally, if the next k skaters all have the same mark, then all should be assigned the next ordinal, and the following k - 1 ordinals are skipped.2
Here’s an example that might make this clearer. The first row represents the marks given by a single judge to 10 skaters. The second row are the assigned ordinals.
The ranking factors are at the heart of the 6.0 judging system. They are computed for each skater based on the ordinals for that skater from each of the judges.
The following table gives an example of how to compute the ranking factors for a skater, given the ordinals from 7 judges.
The ranking factors allow two skaters to be compared to see which is better. For M, TOM, and TO, smaller is better, but for GM, larger is better (more judges in favor of the skater).
Skaters are compared on the factors M, GM, TOM, TO, in order. The first factor in which the two skaters differ determines which is better. Only if they are the same is the next factor examined. If two skaters are the same in all four factors, then they are tied.
In this step, all skaters are sorted according according to the “better than” order described above.4
The final placement is given by the position of the skater in the sorted list, except that ties must be handled as in the first step. Namely, two skaters who are tied both receive the higher place and the next place is skipped.
Your assignment will be graded according to the scale given in Figure 1.
# | Pts. | Item |
1. | 5 | A well-formed Makefile or makefile is submitted that specifies compiler options -O1 -g -Wall -std=c++11. |
2. | 5 | Running make successfully compiles and links the project and results in an executable file scorer. |
3. | 40 | Running scorer on the graders’ test files produces correct output or a reasonable error message in case of bad input. |
4. | 10 | Each class and function definition is preceded by a comment that describes clearly what it does. |
5. | 30 | |
6. | 10 | All relevant requirements from PS1 and PS2 are followed. |
100 | Total points. |
|