The solution is going to cover the remaining tasks for part five.
The third test case tells us the test, if the plays for Chaser, then test if a team score update's
by a constant named Walthall points.
I'm going to create another unit has named a score test.
And inside, Quiverful scored test, we're going to get the team named Gryffindor.
And then from the game, object call a method named score.
And the method receives one object, the team for which you want to update the score.
Call this method twice.
Remember, from the requirements, Walthall points equals 10, so we're going to assert the team scores
20.
After we call the method game gets scored.
I'm going to create a function that returns void called Coffle Score.
And the unit test implies we need to pass a time object into our function team team.
And we need to update the number of points by ten, but please do not play in the right 10, it's really
dangerous to have loose constants in your code, especially when they're important, because you could
change them by a mistake until like we saw in the Constants lesson wall to declare a private static
final constant while full points that equals 10.
And now we can just reference points.
This is much safer.
And going back up, we could also make this public, I wouldn't be too worried because it's final so
it can never be changed by the color, but there's no reason to make it publicly available outside the
class.
And even if you did, it's good practice to just give it a go getter that returns a copy of that value.
If you want to make it public, feel free to do so.
It's just a matter of opinion at this point.
You know, back here, I can just say game Walthall points times to.
Much better, but let's actually run the test.
And it fails, it means I must have a bug expected 20 bagger about 10.
Silly me, getting at a unit test to check my mistake, all I'm doing is resetting the score to 10 every
time, but instead I need to get the current score.
Tend to it and return that as the updated score.
Run on your test now.
And it passes perfect.
Can this be a refactored, not really.
All right, that's it for that.
The final test case tells us the test, if the plays for speaker, then check if a team score update's
by a constant named snitch points.
I'm going to create another unit test named Catch Snitch Test that's a bit of a tongue twister.
An inside catch snitch test, we're going to get the team name slither in.
And then from the game, object call a method named catch snitch.
And the method is going to receive one object, the team for which you want to update the score.
And recall from the requirements it tells us to research the team's score should be whatever the constant
game snitch points amounts to.
OK, now inside GamerGate, the write code to make the test fail, I'm going to create a function called
catch snitch.
And the unit test implies we need to pass a time object into our function team team.
For now, we'll do nothing, make the test fail.
Actually, we can't even run our test because this doesn't exist yet, let's just assume it's going
to fail.
And now for that particular team, we need to update their score by a constant named snitch points.
Private static, final, constant snitch points, that equals 150.
And since the constant is private, we can provide it with a GETER.
And now we can update the score for the team that gets passed in this third set score.
First, we'll get their current score and update it by the number of snitch points.
Then it passes.
Can the code be refactored?
Not really.
OK, now let's run every test to make sure we don't have any bugs.
And or we can move on to the next task.