WEBVTT

00:02.490 --> 00:04.500
An that's it.

00:04.590 --> 00:07.110
So you run this

00:10.990 --> 00:12.370
well you can't run it quite yet.

00:12.370 --> 00:14.490
So let's implement.

00:14.500 --> 00:15.760
Want to play again.

00:19.500 --> 00:20.850
And then run it.

00:20.850 --> 00:30.160
See so let's just add it after the game.

00:30.490 --> 00:38.900
All that.

00:39.370 --> 00:39.740
Here

00:44.470 --> 00:46.840
in for one to play.

00:46.900 --> 00:47.570
Ken

00:52.680 --> 00:55.020
are you going to use our

00:58.650 --> 01:00.280
two functions.

01:00.290 --> 01:05.020
You have these two in fact use this function.

01:05.220 --> 01:13.880
So let me copy this I'll add it to the declarations yet.

01:14.400 --> 01:16.160
Two declarations

01:26.550 --> 01:27.220
this

01:31.740 --> 01:39.110
these two get character functions and you're going to use that in want to play again to make it easier.

01:39.130 --> 01:49.430
So remember how it works is we're going to have a Auray it's char.

01:49.470 --> 02:02.940
So here's the one for the valid inputs and the only valid inputs right to have are yes and no y in this

02:05.120 --> 02:15.940
and how we're going to say is your response Z to get character and we're calling the function.

02:15.950 --> 02:21.290
And then we call it with the prompts would you.

02:23.940 --> 02:26.630
Again and yes or no.

02:29.700 --> 02:36.500
And this is the Arab Spring and we actually are defined it above the error string.

02:37.520 --> 02:45.760
And valid inputs and the length of how many got there.

02:46.410 --> 02:53.160
And then all we have to do is a return response equal to it's

02:57.630 --> 03:01.860
so let's actually run this and see what we have so far.

03:03.030 --> 03:15.480
So hello and see it through the gallows and it drew five dashes right and now it's asking see if you

03:15.480 --> 03:16.690
want to play again.

03:17.720 --> 03:19.980
So no.

03:20.390 --> 03:24.950
So now let's actually do the rest of play again.

03:26.090 --> 03:29.180
So we know our draw board works.

03:29.180 --> 03:34.890
That's good really help and it's just implement the rest of the game.

03:34.970 --> 03:53.900
So while not is over in to the number of guesses laughs and the hidden phrase

03:56.590 --> 03:57.110
dher

03:59.730 --> 04:10.820
raise and the length and I'm going to pass the secret phrase like well just to not have to call Sterlite

04:10.830 --> 04:14.740
again mostly and just kind of notice that.

04:15.230 --> 04:16.390
Rob Ford.

04:16.520 --> 04:22.170
There should be no pointer.

04:22.280 --> 04:23.460
This guy doesn't own it.

04:25.770 --> 04:31.490
So that's copying pasting things or is bad usually.

04:31.910 --> 04:37.880
So try not try to avoid it if you can cause bad things will happen and so should be no pointer for hidden

04:37.880 --> 04:41.780
phrase in draw the draw board.

04:44.650 --> 04:45.430
So

04:49.040 --> 04:54.430
let's just skip implementing this for now and just get the rest of the stuff we'll get the guest guess

04:54.560 --> 04:57.280
is just a character right.

04:57.530 --> 05:02.560
So get the gas and to do that we will

05:05.190 --> 05:08.920
have this gas function improvement

05:11.280 --> 05:21.910
and the other one is the update board I'm just following our top down design right now I'm not implementing

05:21.910 --> 05:28.240
anything and passing the gas and the hidden phrase

05:32.850 --> 05:39.170
and the secret phrase.

05:39.420 --> 05:43.590
And again I'll pass in the secret.

05:43.780 --> 05:48.120
It's like.

05:48.540 --> 05:50.960
And then I will draw the board.

05:54.530 --> 05:56.520
That's Amber.

05:56.670 --> 06:02.060
Yes is left and the

06:06.570 --> 06:07.230
phrase

06:12.400 --> 06:21.460
so soft implement get gas update board and it came over and let's just round out play games.

06:21.470 --> 06:23.880
Would have to come to it again this way.

06:23.910 --> 06:33.530
So it's an say the secret phrase here and a number of guesses.

06:35.090 --> 06:43.680
What and the last thing we need to do is since we own that pointer we have to delete it.

06:43.830 --> 06:49.220
So pointer hidden goodies like this.

06:51.360 --> 06:54.170
So it's only good for the duration of the game.

06:54.190 --> 06:55.680
You know other words.

07:08.770 --> 07:12.450
So now let's finish all this stuff.

07:15.020 --> 07:18.370
Seltsam might get guess.

07:18.400 --> 07:22.010
So it's going to turn a character.

07:22.600 --> 07:27.960
Will actually be using get character for our get gas function.

07:28.150 --> 07:30.070
Character.

07:30.140 --> 07:30.700
Yes.

07:30.780 --> 07:32.790
Returns nothing.

07:34.740 --> 07:35.500
Copy that.

07:39.700 --> 07:42.220
And let's

07:45.440 --> 07:49.390
in and really care about ordering too much right here.

07:50.470 --> 07:53.140
And it's going to do

07:56.820 --> 07:57.840
is

08:01.620 --> 08:14.270
very simple return get character using that function again these input guests and it takes in the input

08:14.310 --> 08:22.840
air strings but are straight.

08:23.210 --> 08:23.720
That's it.

08:27.410 --> 08:31.950
And let's do the date for now.

08:33.120 --> 08:38.310
Even more interesting function.

08:38.350 --> 08:41.650
So it's not going to return anything.

08:41.650 --> 08:52.990
So the guest is a character the changes changes no pointer rank because update or doesn't own it and

08:53.690 --> 08:56.600
you can change it so it should just be a char a star.

08:56.650 --> 09:07.110
This and the secret phrase is a character attracted me to a concert.

09:07.250 --> 09:09.030
This never changes either.

09:10.050 --> 09:10.640
That

09:13.400 --> 09:25.800
and Lanc and we're actually missing something the number of guests is left and that will be a reference

09:27.370 --> 09:37.990
Amber guesses less as we can update the number of guesses left and it will change our callers version.

09:38.150 --> 09:44.620
And that's why it's that reference so it's copy this

09:48.100 --> 09:54.780
here and still pass in the number of guesses left.

10:00.770 --> 10:03.880
And so put it right here.

10:06.910 --> 10:07.750
OK.

10:09.260 --> 10:13.730
So date the board.

10:13.820 --> 10:25.530
So how did we do this so we're basically just looking to see if we found a letter or we found the guess

10:25.590 --> 10:28.440
in the secret phrase.

10:28.440 --> 10:28.750
Right.

10:28.770 --> 10:36.530
And if we did we reveal the that letter and each position of the hidden phrase.

10:36.660 --> 10:45.930
What we didn't do here is to see if because since like an uppercase H is not the same as a lowercase

10:45.990 --> 10:49.530
H we have to ignore case here.

10:49.620 --> 10:56.560
So we're going to ignore the case of the secret phrase.

10:56.880 --> 11:06.480
So we're actually going to make this to lower because our guess is also in lowercase so that and in

11:06.480 --> 11:13.470
fact what we should do here instead is actually say secret phrase.

11:13.620 --> 11:16.500
Because what if they typed in.

11:17.730 --> 11:24.740
Hello right or and high like this.

11:24.800 --> 11:26.900
OK that's a secret phrase.

11:27.040 --> 11:35.330
So if they typed in h it should match h this H which is uppercase and this H.

11:35.590 --> 11:43.850
And if we said it to the guess it would this would be lowercase which is not correct.

11:44.140 --> 11:49.300
Like this what we want to do is just keep it the same as the secret phrase.

11:49.330 --> 12:03.940
So it's you that so here we're going to say have we found one or no

12:07.120 --> 12:15.950
and we're going to use that for for decrementing the number of guesses later.

12:16.200 --> 12:34.970
So for he goes to zero eyes less than the length of or secret phrase like sorry secret Rhee's Lanc

12:37.820 --> 12:40.150
plus.

12:40.370 --> 12:54.170
And if to lower your secret phrase I call to you the guess.

12:54.220 --> 13:02.790
So if the lower case version of the secret phrase is current letter is the same as the guess then we

13:02.790 --> 13:17.580
should say hidden or no pointer in phrase eyes equal to the secret phrase.

13:17.820 --> 13:21.150
And that's not to lower of the secret phrase of I.

13:21.150 --> 13:27.940
Because again we want to preserve the case when it's output but not when we check.

13:29.960 --> 13:33.240
And then we have found it true.

13:34.780 --> 13:43.050
And here if we we didn't find it right then we should

13:45.890 --> 13:48.410
subtract one from the number of guesses left

13:57.640 --> 14:02.170
that is update board so we're almost done.

14:02.360 --> 14:11.820
We only have two functions left so we should implement is

14:15.140 --> 14:16.420
to do that now.

14:22.360 --> 14:24.910
So it's over.

14:25.020 --> 14:28.000
Who'll right turns.

14:28.010 --> 14:31.930
Boolean it's over or not the number of guesses left.

14:31.930 --> 14:37.520
So this would just be a copy because you don't need to know or it doesn't need to change it at all.

14:37.540 --> 14:51.510
So this is the conc char star and no pointer rank doesn't own it.

14:55.100 --> 14:56.290
Copy this.

14:58.470 --> 15:03.960
It Right after the oared.

15:04.030 --> 15:05.770
So how do you know if it's over.

15:05.770 --> 15:09.340
So we go through.

15:09.450 --> 15:15.770
So we go through each of the characters in the hidden phrase to see if it's a dash.

15:16.110 --> 15:24.910
If we do have a dash and it can't this game can't be over or if the number of guesses is 0 then it's

15:24.910 --> 15:25.400
over.

15:25.440 --> 15:26.280
Right.

15:26.590 --> 15:27.310
So

15:30.730 --> 15:36.270
three here so see bhool has Dasch.

15:36.510 --> 15:40.360
All else for.

15:40.570 --> 15:52.540
So your source then the secret phrase like boss.

15:52.800 --> 16:02.960
If the new pointer didn't phrase is equal to a dash

16:09.190 --> 16:10.650
then we do have ash

16:17.360 --> 16:25.370
and we want to just break out of the loop because now we know the game or at least has a dash so at

16:25.370 --> 16:32.920
least that portion of the game is not over a number of guesses left.

16:32.940 --> 16:46.110
It's 0 or doesn't have a dash and you know is over.

16:46.200 --> 16:51.900
And finally we have the display results

16:53.990 --> 17:01.250
so it's implement that fairly simple.

17:01.440 --> 17:02.940
So it's copy

17:12.660 --> 17:14.260
it won't return anything

17:16.970 --> 17:24.430
and it'll take a constant Shore star.

17:24.660 --> 17:24.920
Number

17:32.960 --> 17:41.740
it's meant that it's so should be pretty much the same as the number guesser version so if the number

17:42.780 --> 17:49.100
guesses length is greater than zero then you got it right.

17:49.190 --> 17:51.920
C-O got it.

17:53.740 --> 17:56.040
The word is

18:02.540 --> 18:03.600
free.

18:03.660 --> 18:04.590
Yes.

18:07.590 --> 18:08.190
Tres

18:10.790 --> 18:11.390
else

18:18.040 --> 18:19.100
didn't you get it.

18:22.670 --> 18:22.970
Free.

18:23.220 --> 18:23.780
It's

18:29.520 --> 18:29.930
so

18:37.520 --> 18:38.200
phrase

18:44.480 --> 18:47.490
so hopefully that makes sense as well.

18:49.280 --> 18:59.220
So I we're basically done written like 500 lines of code Well probably not because of all this

19:01.970 --> 19:12.360
is comments here but let's read this hidden it's so me that will be there.

19:12.380 --> 19:19.880
So say hello everyone.

19:20.230 --> 19:23.630
So we have a nice Remy.

19:23.650 --> 19:23.930
Hello.

19:23.930 --> 19:25.220
Hi.

19:29.230 --> 19:39.890
Each local lowercase So center so nicely we have the dashes of each thing.

19:39.890 --> 19:42.560
So say H.

19:43.130 --> 19:52.610
And notice that it's said or it output a capital H and a lowercase h properly even though we just entered

19:52.610 --> 19:53.860
a lower case H.

19:53.920 --> 19:54.930
That's working.

19:58.890 --> 20:00.880
How right.

20:00.970 --> 20:01.530
Let's guess.

20:01.560 --> 20:03.700
Let's get it wrong.

20:03.820 --> 20:07.700
W o that head.

20:08.410 --> 20:30.320
Say a Q No and say F is the arm say G the other arm and say k

20:33.600 --> 20:34.620
are almost dead.

20:34.650 --> 20:40.660
So let's actually lose this one and that's a B.

20:41.000 --> 20:43.240
So you can get at the phrases.

20:43.370 --> 20:43.760
Hello.

20:43.760 --> 20:44.810
Hi everyone.

20:44.910 --> 20:45.490
OK.

20:45.740 --> 20:47.920
Would you like to play again.

20:48.070 --> 20:50.000
Let's just rerun this.

20:50.180 --> 21:00.530
So we have a clear console and I'll show you an and this time this is it.

21:00.720 --> 21:07.950
Each see all the R Y

21:11.380 --> 21:11.860
II

21:16.490 --> 21:20.010
inch and a.

21:20.110 --> 21:22.240
Got it.

21:23.030 --> 21:27.900
So that's the major implementation of hangman.

21:28.260 --> 21:32.500
We're following along and I went a little bit quickly.

21:33.650 --> 21:43.550
In the next lecture though I want to go over some odds and ends with this game and see if we can do

21:43.550 --> 21:46.040
a little bit more to it and change a little bit more.

21:46.040 --> 21:49.480
So I will see you in the next lecture.
