Create a class
named ScoreTracker
that we'll use to keep track of the scores of two players who are
playing a game.
Players playing this game always take turns, and Player 1 always plays first.
Both players scores start at zero.
Each ScoreTracker
should provide a method score
that accepts a number of points and does not return a value.
If it is Player 1's turn, the points (which might be negative) get added to their score.
Otherwise they get added to Player 2's score.
You should also provide a method currentlyAhead
that returns 1
if Player 1 is ahead, 2
if Player 2 is ahead,
and 0
if it's a tie.
You should not expose any of your state publicly, and ScoreTracker
does not need to provide a public constructor.
When your class is complete, here is how it should work:
You're challenge is to write tests for this problem described above.
Stuck? You may find these lessons helpful: