Assignment 2 - Maintaining a Highest Scores List

due Tuesday, 1/29   9:30 am

The purpose of this assignment is to maintain a list of 10 highest scores for some game.  The assignment requires building and using two libraries and reading and writing a binary file.  The program will make use of an input file containing game scores.

Program Requirements

The Date Library

The Date library should contain a Date class.  The Date class should contain a time_t data member to store the date.
The Date class should contain

The Score library

The Score library should contain a Score class and an overloaded insertion operator to display Score objects.
The Score class shold contain

The Input File - Get it here

It looks like this - there are about 20 records in the file

Gertrude        08Aug05      34
Mac the Knife                82
Luke Skywalker  06Aug14      59
Harry S Truman  10/19/06     52
Martha                       30
Clyde           09/11/17     98
Clyde           1325122744   31
Mick Jagger     04Nov03       7
...

The binary file

The Scores data must be stored in a binary file in sorted order.
A maximum of 10 highest scores will be stored in the binary file.
The binary file should be read in before each record in the input file is processed.
The binary file should be written each time a new score is inserted into the list of highest scores.

A sample main

int main()
{
    Score scores[MaxNumberOfScores];

    ifstream fin(InputFile);
    if (!fin)
    {
        cerr << "Unable to open input file " << InputFile << endl;
        exit(1);
    }

    Score newScore;
    unsigned numScores;
    bool updateScores = false;
    eraseScoresFile(ScoresFile);

    while (processInputFile(fin, newScore))  // read a record from input file
    {
        // read binary Scores file
        numScores = getScoresFromFile(ScoresFile, scores);
       
        if (numScores < MaxNumberOfScores)    // Less than 10 Scores
        {
            scores[numScores++] = newScore;
            updateScores = true;
        }
        else if (scores[numScores - 1] < newScore)   // newScore > lowest of Top Scores
        {
            scores[numScores - 1] = newScore;        // add newScore to Top Scores
            updateScores = true;
        }
        else updateScores = false;

        if (updateScores)
        {
            sort(scores, numScores);                 // sort Scores

            for (auto i = 0U; i < numScores; ++i)
                cout << left << setw(3) << i+1 << scores[i] << endl;
            cout << "----------------------------------\n";
           
            // Write binary Scores file
            writeScoresToFile(ScoresFile, scores, numScores);
        }
    }
}

Program Output

1  Gertrude           34  08/08/05
----------------------------------
1  Mac the Knife      82  01/01/19
2  Gertrude           34  08/08/05
----------------------------------
1  Mac the Knife      82  01/01/19
2  Luke Skywalker     59  08/06/14
3  Gertrude           34  08/08/05
----------------------------------
1  Mac the Knife      82  01/01/19
2  Luke Skywalker     59  08/06/14
3  Harry S Truman     52  10/19/06
4  Gertrude           34  08/08/05
----------------------------------
1  Mac the Knife      82  01/01/19
2  Luke Skywalker     59  08/06/14
3  Harry S Truman     52  10/19/06
4  Gertrude           34  08/08/05
5  Martha             30  01/01/19
----------------------------------
1  Clyde              98  09/11/17
2  Mac the Knife      82  01/01/19
3  Luke Skywalker     59  08/06/14
4  Harry S Truman     52  10/19/06
5  Gertrude           34  08/08/05
6  Martha             30  01/01/19
----------------------------------
1  Clyde              98  09/11/17
2  Mac the Knife      82  01/01/19
3  Luke Skywalker     59  08/06/14
4  Harry S Truman     52  10/19/06
5  Gertrude           34  08/08/05
6  Clyde              31  02/20/28
7  Martha             30  01/01/19
----------------------------------

...

1  Clyde              98  09/11/17
2  Mac the Knife      82  01/01/19
3  Luke Skywalker     59  08/06/14
4  Harry S Truman     52  10/19/06
5  Gertrude           45  04/07/07
6  Gertrude           34  08/08/05
7  C3P0               32  07/28/15
8  Clyde              31  02/20/28
9  Martha             30  01/01/19
10 Mick Jagger         7  11/04/03
----------------------------------
1  Clyde              98  09/11/17
2  Mac the Knife      82  01/01/19
3  Mac the Knife      67  05/11/13
4  Luke Skywalker     59  08/06/14
5  Harry S Truman     52  10/19/06
6  Gertrude           45  04/07/07
7  Gertrude           34  08/08/05
8  C3P0               32  07/28/15
9  Clyde              31  02/20/28
10 Martha             30  01/01/19
----------------------------------
1  Clyde              98  09/11/17
2  Bonnie             96  04/25/12
3  Mac the Knife      82  01/01/19
4  Mac the Knife      67  05/11/13
5  Luke Skywalker     59  08/06/14
6  Harry S Truman     52  10/19/06
7  Gertrude           45  04/07/07
8  Gertrude           34  08/08/05
9  C3P0               32  07/28/15
10 Clyde              31  02/20/28
...

Do not submit your assignment code for grading ...

Instead of emailing all of your source for building and testing by the instructor, submit the following as proof of your successful completion:
  1. All of your sources files and header files for the libraries and the application.  Places all source files and header file in one compressed (zipped) folder.  Do not include project files, object files, library archives or executables.
  2. An output file of the assignment results.  It should look like that shown above.
  3. A screen image showing the assignment application build, including compilation and linking options.  Here is a sample using Code::Blocks.