Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,330 --> 00:00:05,730
Onwards to part two, and the next task is to start the game by explaining the rules, all you have
2
00:00:05,730 --> 00:00:06,950
to do is print the rules.
3
00:00:06,960 --> 00:00:09,150
So I'm going to make eight print statements.
4
00:01:10,620 --> 00:01:14,520
I'm going to apply the new lines where it's necessary, so here, in here.
5
00:01:28,360 --> 00:01:33,400
And where you see a vertical line, we're going to you scan the next line to get the user to press enter
6
00:01:33,400 --> 00:01:34,180
when they're ready.
7
00:01:48,730 --> 00:01:53,530
And for the sake of running the task, I'm going to remove this function call and then I'll compile
8
00:01:53,530 --> 00:01:54,460
and run the code.
9
00:02:09,650 --> 00:02:13,330
Seems like we're off to a good start, the game starts by explaining the rules.
10
00:02:18,890 --> 00:02:23,810
All right, so now once the user is ready, I have to present them and the computer with a card.
11
00:02:26,590 --> 00:02:33,010
This is as simple as calling the random card function twice, so I'll set a variable string, your card
12
00:02:33,460 --> 00:02:39,730
is equal to a random card and string computer card is equal to another random card.
13
00:02:46,450 --> 00:02:51,280
What I'll do now is I'll print each result according to the instructions I left you in Task three,
14
00:02:52,240 --> 00:02:53,950
so I'll print here's your card.
15
00:02:59,140 --> 00:03:00,760
Then I'll print the user's card.
16
00:03:09,750 --> 00:03:13,470
Then I'll print the new line, as mentioned in the instructions.
17
00:03:19,900 --> 00:03:23,530
And I'll continue printing everything according to the instructions.
18
00:03:39,600 --> 00:03:41,600
OK, you're running my code once more.
19
00:03:52,500 --> 00:03:56,010
Presents me with a card and it presents the computer with a card as well.
20
00:03:56,850 --> 00:04:02,100
I'm going to rerun my code multiple times to make sure the computer and I keep getting random cards.
21
00:04:05,060 --> 00:04:07,040
And everything seems to be working perfectly.
22
00:04:17,959 --> 00:04:22,940
All right, it's time for task, for the next task is to get the dealer to draw five cards.
23
00:04:23,420 --> 00:04:27,320
All this means is that we need to create a for loop that runs exactly five times.
24
00:04:27,590 --> 00:04:30,620
And every time it runs, it's going to call the random card function.
25
00:04:31,850 --> 00:04:36,680
So first, I'm going to print the message now the dealer will draw five cards, press enter to continue.
26
00:04:44,140 --> 00:04:46,960
And then I'll create a for a loop that started equals zero.
27
00:04:50,730 --> 00:04:58,320
Keeps running till I'm less than five I a plus plus in this loop is going to run five times and we want
28
00:04:58,320 --> 00:05:01,370
each card in the river to show every time the user presses enter.
29
00:05:01,830 --> 00:05:06,270
So it only makes sense that we write scan the next line at the beginning of every run.
30
00:05:07,260 --> 00:05:12,600
And after the user presses enter at the beginning of every run, I'm going to draw a random card and
31
00:05:12,600 --> 00:05:13,140
print it.
32
00:05:43,760 --> 00:05:48,440
So that gives me and the computer recovered card, and now we're inside the loop, and every time I
33
00:05:48,440 --> 00:05:52,460
press enter, it draws a new card and it's going to do that five times.
34
00:05:55,610 --> 00:05:59,030
Now, before drawing each card, I want to print the order that it appears in.
35
00:06:05,260 --> 00:06:07,330
So what I can do is print card.
36
00:06:19,870 --> 00:06:23,470
And connect the current value of the counter I during each run.
37
00:06:45,630 --> 00:06:50,790
And now, every time I press enter, it draws a new card and it prints the order that the card appears
38
00:06:50,790 --> 00:06:54,750
in, but it starts at zero and it ends at four, which is kind of weird.
39
00:06:56,940 --> 00:07:02,250
But that's to be expected because the loop starts with equaling zero and it's going to keep running
40
00:07:02,250 --> 00:07:06,420
until it is less than five four, so it's going to run five times.
41
00:07:06,420 --> 00:07:09,240
And during each run, it is going to equal zero one, two or three.
42
00:07:09,240 --> 00:07:11,510
And then the fifth run, it's going to equal four.
43
00:07:12,480 --> 00:07:17,580
But what I can do is have the counters started I equals one and make sure it keeps running as long as
44
00:07:17,580 --> 00:07:19,550
I is less than or equal to five.
45
00:07:20,100 --> 00:07:24,690
So this time, given our starting point and the stop condition, the loop is still going to run five
46
00:07:24,690 --> 00:07:30,720
times, but the counter starts at 1:00 and it keeps coming up until it equals five, beyond which the
47
00:07:30,720 --> 00:07:33,000
condition turns false and the loop breaks.
48
00:07:44,500 --> 00:07:49,180
So here we enter the for loop, the counter starts at one and the loop keeps running until I equals
49
00:07:49,180 --> 00:07:51,010
five and that is perfect.
50
00:07:51,040 --> 00:07:52,570
That is all for task for.
51
00:07:53,650 --> 00:07:54,970
I'm just going to zoom in a little bit.
52
00:07:59,570 --> 00:08:04,700
But as you can see, the only hard part was really creating the random card function, the whole code.
53
00:08:04,940 --> 00:08:08,210
Up to this point, I just been calling the function in different places.
54
00:08:12,010 --> 00:08:16,660
OK, so we're done task for moving on to Task five, we need to determine the winner.
55
00:08:18,210 --> 00:08:22,120
So if you remember in TASC three, the user was given a card and so was the computer.
56
00:08:22,680 --> 00:08:29,130
I need to determine how many times the user's card matches with the river and how many times the computer's
57
00:08:29,130 --> 00:08:30,440
card matches with the river.
58
00:08:31,200 --> 00:08:33,870
And so you'll notice that I left you to integer variables.
59
00:08:33,900 --> 00:08:35,450
They should already be in your workbook.
60
00:08:36,030 --> 00:08:41,640
So inside the loop, as the dealer draws the river, I'm going to compare the user's card against the
61
00:08:41,640 --> 00:08:43,770
card that's currently being drawn.
62
00:08:44,550 --> 00:08:48,480
And if the user's card equals draw the card that's being drawn.
63
00:08:50,660 --> 00:08:55,460
It means the user has a match, and in which case I'll increase the number of matches by one.
64
00:09:01,270 --> 00:09:03,340
And if it matches the computers card.
65
00:09:13,340 --> 00:09:15,770
I'll increase the number of computer matches.
66
00:09:29,540 --> 00:09:35,330
And so now I'm going to print your number of matches is and I'll conduct your matches.
67
00:09:43,320 --> 00:09:45,840
Then I'm going to print the computer number of matches.
68
00:09:50,360 --> 00:09:52,490
Connecting the number of computer matches.
69
00:10:15,420 --> 00:10:18,600
OK, so I got a king and the computer got a 10.
70
00:10:19,050 --> 00:10:24,480
Hopefully I can get more matches than the computer and it seems that none of us match with the ace or
71
00:10:24,480 --> 00:10:26,670
the three or the seven or the four.
72
00:10:27,120 --> 00:10:28,950
And we both have zero matches.
73
00:10:29,610 --> 00:10:30,420
Try this again.
74
00:10:35,710 --> 00:10:38,110
Now I have a six and the computer has an eight.
75
00:10:39,230 --> 00:10:44,770
But when it seems the computer has a match with eight oh and I match with a six boy, this is exciting,
76
00:10:44,780 --> 00:10:48,470
seven nine and it's a tie, OK, whatever.
77
00:10:48,480 --> 00:10:51,400
But in the end, it reflects an accurate score of one and one.
78
00:10:51,980 --> 00:10:54,380
I have one match and the computer has one match.
79
00:10:56,280 --> 00:11:00,870
And now for the last step, after the dealer dragged the river, we need to determine the winner.
80
00:11:03,750 --> 00:11:08,010
So if your number of matches, the users matches, is bigger than computer matches.
81
00:11:12,630 --> 00:11:14,340
We're going to print Ewin.
82
00:11:21,320 --> 00:11:23,720
But if the computer ends up having more matches.
83
00:11:33,500 --> 00:11:35,390
Print the computer wens.
84
00:11:40,490 --> 00:11:41,600
And if they're equal.
85
00:11:47,510 --> 00:11:48,740
Everyone wins.
86
00:11:58,620 --> 00:12:00,000
So it seems I have three.
87
00:12:00,030 --> 00:12:01,400
The computer has a J.
88
00:12:08,480 --> 00:12:10,640
It's a tie and everyone wins.
89
00:12:11,090 --> 00:12:13,520
Let's try and test a scenario where one of us wins.
90
00:12:24,700 --> 00:12:25,690
And it's a tie again.
91
00:12:30,390 --> 00:12:34,200
Oh, I think the computer is going to win this one, and it does.
92
00:12:35,130 --> 00:12:37,230
Let's try and test the scenario where I would win.
93
00:12:40,870 --> 00:12:41,810
So I have a 10.
94
00:12:41,860 --> 00:12:47,700
The computer has a niece and it matches with two other aces in the river, so it wins once again.
95
00:12:48,430 --> 00:12:51,330
And I'm just really unlucky at these Jova games.
96
00:12:51,970 --> 00:12:55,220
But anyways, I'm confident that everything works the way it should.
97
00:12:56,080 --> 00:12:56,740
That is all.
98
00:12:56,740 --> 00:13:01,990
I hope you had fun building poker, Rido, and I hope the solution clarifies any doubts you were having,
99
00:13:01,990 --> 00:13:07,330
because your big challenge is going to require you to build a similar project, blackjack.
100
00:13:07,750 --> 00:13:08,710
So I hope you're ready.
10045
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.