Look at the score.cpp file that contains the Score class. You can copy it over to your current directory using:
wget http://www.cs.csubak.edu/~melissa/cs222/score.cppThis is the Score class that we discussed in lecture, which will allow one to store integers greater than INT_MAX. This class currently has several helper functions and two operators defined, but it does not have the following basic operators needed to provide a standard interface. You will need to define these operators for the lab:
>>
The input operator. It is a friend function that takes
two parameters. The first parameter is the input stream. The second parameter
is the class object. Input into a temporary integer and then use an if-else
statement similar to the integer conversion constructor to set the counters.
<<
The output operator. It is a friend function that
takes two parameters. The first parameter is the output stream and the second
parameter is the class object. Call the helper function
formatScore()
in the class object with the output
stream as the argument to the member function.
+
The addition operator. It is a friend function that takes
two parameters. It takes two class objects and returns a new class object that
reflects the sum of the scores. This is somewhat like the += operator, but you
are creating a new Score object to hold the sum instead of adding it into the
current Score object. At the top of the function, declare a temporary Score
object called temp. Then follow this pseudocode:
Set temp.million_counter equal to the sum of the two objects' millions' counters Set temp.billion_counter equal to the sum of the two objects' billions' counters Call temp.normalizeScore() in case the sum of the millions' counters is >= THRESHOLD Return temp
Email me your completed source code. Make sure both partners names are in the comment section if you worked with a lab partner.