Define a class
named Points
.
It should have a public instance method named score
and a second named penalty
, both taking a single Int
argument.
score
adds the passed number of points to the score, while penalty
removes the passed number of points from
the score.
Both functions should return the new score after the change is completed.
Your class should also provide a constructor taking a single Int
argument that sets the initial score.
Note that your Points
class should not allow modifications to the score
except using the score
and penalty
methods.
So when you are finished your class should work as follows:
Stuck? You may find these lessons helpful: