Look at the score.cpp file that contains the Score class. You can copy it over to your current directory using:
cp /usr/users/mdanfor/public_html/cs222-w07/score.cpp .It has constructors and basic member functions defined, but no operators are defined. Until the operators are defined, the code will not compile because main() is using the operators. You will need to define the following operators:
>>
- The input operator. The first parameter is the input
stream. The second parameter is the class object. You will set the value of
score and o_score in the class object if the number read in is greater than
0. Use the constructor that takes an integer as a reference for how to set
score and o_score.
<<
- The output operator. The first parameter is the
output stream and the second parameter is the class object. Call the member
function format_score()
in the class object with the output
stream as the argument to the member function.
+
- The addition operator. It takes two class objects and
returns a new class object that reflects the sum of the scores. Look at the
adj()
member function to see how to check for overflow (a number
too big to be stored in an integer). Don't forget to take the sumation of
o_score for both parameters, otherwise the billions counter will be lost.
<
- The less than comparison operator. It takes two
class objects and returns a bool. Look at the compare_scores()
function discussed in lecture for hints on how to implement this operator.