Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,690 --> 00:00:03,719
The solution is going to cover the remaining tasks for part five.
2
00:00:04,750 --> 00:00:09,700
The third test case tells us the test, if the plays for Chaser, then test if a team score update's
3
00:00:09,700 --> 00:00:11,920
by a constant named Walthall points.
4
00:00:14,420 --> 00:00:17,450
I'm going to create another unit has named a score test.
5
00:00:26,180 --> 00:00:30,110
And inside, Quiverful scored test, we're going to get the team named Gryffindor.
6
00:00:38,460 --> 00:00:41,940
And then from the game, object call a method named score.
7
00:00:45,000 --> 00:00:49,380
And the method receives one object, the team for which you want to update the score.
8
00:00:51,400 --> 00:00:52,660
Call this method twice.
9
00:00:55,760 --> 00:01:00,740
Remember, from the requirements, Walthall points equals 10, so we're going to assert the team scores
10
00:01:00,740 --> 00:01:01,310
20.
11
00:01:05,019 --> 00:01:07,360
After we call the method game gets scored.
12
00:01:12,370 --> 00:01:15,820
I'm going to create a function that returns void called Coffle Score.
13
00:01:20,290 --> 00:01:24,700
And the unit test implies we need to pass a time object into our function team team.
14
00:01:29,870 --> 00:01:35,690
And we need to update the number of points by ten, but please do not play in the right 10, it's really
15
00:01:35,690 --> 00:01:40,820
dangerous to have loose constants in your code, especially when they're important, because you could
16
00:01:40,820 --> 00:01:46,340
change them by a mistake until like we saw in the Constants lesson wall to declare a private static
17
00:01:46,340 --> 00:01:49,190
final constant while full points that equals 10.
18
00:02:02,430 --> 00:02:04,560
And now we can just reference points.
19
00:02:04,620 --> 00:02:05,730
This is much safer.
20
00:02:09,030 --> 00:02:14,400
And going back up, we could also make this public, I wouldn't be too worried because it's final so
21
00:02:14,400 --> 00:02:19,380
it can never be changed by the color, but there's no reason to make it publicly available outside the
22
00:02:19,380 --> 00:02:19,880
class.
23
00:02:20,040 --> 00:02:25,230
And even if you did, it's good practice to just give it a go getter that returns a copy of that value.
24
00:02:25,350 --> 00:02:28,020
If you want to make it public, feel free to do so.
25
00:02:28,020 --> 00:02:30,230
It's just a matter of opinion at this point.
26
00:02:31,250 --> 00:02:34,850
You know, back here, I can just say game Walthall points times to.
27
00:02:43,420 --> 00:02:45,490
Much better, but let's actually run the test.
28
00:02:49,690 --> 00:02:54,190
And it fails, it means I must have a bug expected 20 bagger about 10.
29
00:03:02,760 --> 00:03:08,520
Silly me, getting at a unit test to check my mistake, all I'm doing is resetting the score to 10 every
30
00:03:08,520 --> 00:03:11,220
time, but instead I need to get the current score.
31
00:03:13,360 --> 00:03:15,900
Tend to it and return that as the updated score.
32
00:03:20,780 --> 00:03:21,920
Run on your test now.
33
00:03:24,640 --> 00:03:26,590
And it passes perfect.
34
00:03:29,620 --> 00:03:32,200
Can this be a refactored, not really.
35
00:03:33,790 --> 00:03:35,050
All right, that's it for that.
36
00:03:37,190 --> 00:03:42,950
The final test case tells us the test, if the plays for speaker, then check if a team score update's
37
00:03:42,950 --> 00:03:45,380
by a constant named snitch points.
38
00:03:47,140 --> 00:03:52,360
I'm going to create another unit test named Catch Snitch Test that's a bit of a tongue twister.
39
00:03:56,600 --> 00:04:00,620
An inside catch snitch test, we're going to get the team name slither in.
40
00:04:10,540 --> 00:04:14,110
And then from the game, object call a method named catch snitch.
41
00:04:18,050 --> 00:04:22,010
And the method is going to receive one object, the team for which you want to update the score.
42
00:04:24,520 --> 00:04:29,950
And recall from the requirements it tells us to research the team's score should be whatever the constant
43
00:04:29,950 --> 00:04:32,110
game snitch points amounts to.
44
00:04:51,100 --> 00:04:56,500
OK, now inside GamerGate, the write code to make the test fail, I'm going to create a function called
45
00:04:56,500 --> 00:04:57,460
catch snitch.
46
00:04:58,830 --> 00:05:03,390
And the unit test implies we need to pass a time object into our function team team.
47
00:05:04,260 --> 00:05:06,720
For now, we'll do nothing, make the test fail.
48
00:05:08,720 --> 00:05:13,250
Actually, we can't even run our test because this doesn't exist yet, let's just assume it's going
49
00:05:13,250 --> 00:05:13,700
to fail.
50
00:05:13,910 --> 00:05:19,070
And now for that particular team, we need to update their score by a constant named snitch points.
51
00:05:20,330 --> 00:05:24,410
Private static, final, constant snitch points, that equals 150.
52
00:05:27,930 --> 00:05:31,080
And since the constant is private, we can provide it with a GETER.
53
00:05:41,380 --> 00:05:45,370
And now we can update the score for the team that gets passed in this third set score.
54
00:05:48,660 --> 00:05:52,920
First, we'll get their current score and update it by the number of snitch points.
55
00:06:09,020 --> 00:06:10,070
Then it passes.
56
00:06:14,120 --> 00:06:15,680
Can the code be refactored?
57
00:06:15,890 --> 00:06:16,730
Not really.
58
00:06:17,670 --> 00:06:21,030
OK, now let's run every test to make sure we don't have any bugs.
59
00:06:26,900 --> 00:06:29,660
And or we can move on to the next task.
5882
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.