WEBVTT

00:00.600 --> 00:06.660
So now let's actually start implementing hangman.

00:06.780 --> 00:10.880
So start with step 1 and mean here.

00:11.150 --> 00:12.870
So we have

00:15.840 --> 00:20.160
here is going to do exactly what we did with number gassers.

00:20.160 --> 00:31.850
While I want to play again don't have those functions yet but we make them in.

00:32.200 --> 00:33.070
OK.

00:33.310 --> 00:34.460
That is our step.

00:34.480 --> 00:39.110
One of our top down design right here.

00:40.040 --> 00:43.350
So do it again.

00:43.360 --> 00:47.960
While I want to play again just like we had with number Yassar.

00:48.320 --> 00:54.130
So let's though or declare those functions top here.

00:55.930 --> 01:11.940
What do you say with the name and would want to play an.

01:12.110 --> 01:13.180
There you go.

01:13.730 --> 01:22.240
So next thing I want to do is want to define plaguing

01:26.310 --> 01:27.150
k.

01:27.300 --> 01:28.040
Phew.

01:29.150 --> 01:36.180
Remember what we need to do is have the get the secret phrase make the hidden phrase right.

01:36.180 --> 01:41.040
The one that dashes in and set the number of guesses left and so on.

01:41.090 --> 01:45.320
So let's do this do these three steps first.

01:45.860 --> 01:56.010
So going to need some kind of a C string for the secret where secret phrase

01:58.580 --> 02:07.970
that and it's going to be an array because Raffa read this from the user or from the player self.

02:08.030 --> 02:14.310
So I need to have some kind of like Max link.

02:14.580 --> 02:16.510
It's great.

02:16.960 --> 02:18.480
Us.

02:18.690 --> 02:25.220
And again to set it to some some number do too much just make it long enough.

02:25.610 --> 02:26.810
Why.

02:29.570 --> 02:29.820
CH

02:32.860 --> 02:36.660
reas this way.

02:36.960 --> 02:46.980
And we're also going to have a C string but this is going to be a character pointer to the hidden phrase

02:46.990 --> 02:53.430
because we're going to make this from heap memory.

02:54.470 --> 02:55.620
So with that.

02:55.650 --> 02:57.540
And we have

03:00.900 --> 03:07.620
in this number of guess it's life.

03:08.300 --> 03:14.580
And we are we make this into a constant and smacks

03:16.770 --> 03:19.280
guess's.

03:19.590 --> 03:20.980
Six is

03:34.870 --> 03:45.530
simple so far so we just all we've done is made the variables that we need so we need to actually get

03:45.530 --> 03:51.570
the secret phrase and make the hidden phrase and so on.

03:51.570 --> 03:54.080
So let's do that.

03:54.090 --> 03:57.270
So say

04:01.620 --> 04:10.550
secret or sorry get secret phrase

04:14.800 --> 04:18.960
this and will pass in the secret phrase

04:21.840 --> 04:24.060
and the wink.

04:24.340 --> 04:31.360
Or the maximum number of characters you know great great.

04:31.630 --> 04:32.290
This

04:35.310 --> 04:35.910
care.

04:36.250 --> 04:45.440
So this function will be exactly the same as what we did in the dynamic memory practice.

04:46.060 --> 04:49.780
So are at least very similar.

04:51.950 --> 04:54.530
So let's rate this once.

04:58.920 --> 05:05.230
You're point to it's not going to turn anything right because we're passing in a an array so that will

05:05.230 --> 05:09.900
actually change the array rates raise is passed by reference.

05:09.940 --> 05:16.770
So we're going to change this phrase by adding all the characters in here.

05:17.300 --> 05:21.720
So it's phrase

05:24.930 --> 05:32.180
phrased like this and we're passing a character.

05:33.320 --> 05:33.790
Ray

05:36.850 --> 05:44.150
is this and passed back the maximum way.

05:45.050 --> 05:48.440
Max link back

05:52.360 --> 05:54.410
to find it here

05:59.360 --> 06:00.450
right now.

06:00.930 --> 06:04.920
Yes it's phrase

06:14.800 --> 06:19.570
XBLA.

06:19.700 --> 06:19.960
Hey

06:26.720 --> 06:34.370
And essentially all we're going to do is exactly what we did before

06:37.210 --> 06:40.310
say bhool aliar.

06:40.400 --> 06:40.660
Right.

06:40.670 --> 06:44.710
Just like regular input.

06:46.550 --> 06:47.890
This do

06:51.450 --> 06:57.390
while there's failure which should seem all too familiar.

06:59.690 --> 07:01.940
An failure

07:04.990 --> 07:09.650
to false.

07:09.900 --> 07:10.890
Out.

07:12.360 --> 07:23.690
These enter the Secret Ch phrase we're not using the functions we had we made before in the erate practice.

07:24.040 --> 07:29.210
But we will not for this one anyway but we will be using it.

07:30.460 --> 07:37.920
Get ch as it is and the maximum

07:41.840 --> 07:44.860
Just like we had in the practice day.

07:45.050 --> 07:48.930
If you fail rate

07:53.120 --> 08:03.420
then we should it's clear C nor in need

08:06.740 --> 08:11.130
our constants appear.

08:11.440 --> 08:18.750
Nor are as many and just enough

08:21.290 --> 08:21.730
are

08:24.520 --> 08:25.760
char's this

08:31.810 --> 08:42.350
and once actually have a number constant that's going to be like an integer constants going to be a

08:43.710 --> 08:45.220
star constant.

08:45.770 --> 08:50.600
It's going to be the inputs air string when you use that

08:55.620 --> 08:57.410
input error.

08:58.720 --> 09:01.720
Please try again.

09:03.500 --> 09:06.950
You can also have césarine constants too.

09:06.960 --> 09:13.460
So it doesn't have to be just integers or floats or anything like that can actually have this small

09:16.310 --> 09:18.730
in space.

09:18.800 --> 09:19.250
It's

09:22.040 --> 09:22.480
here.

09:22.480 --> 09:31.980
String all this and we failed here in this case write failure.

09:32.040 --> 09:33.170
It's true.

09:36.920 --> 09:39.750
Otherwise.

09:40.590 --> 09:43.010
So what happened.

09:43.130 --> 09:49.590
What would happen if the length of what the input zero.

09:49.860 --> 09:50.160
Right.

09:50.160 --> 09:53.350
So what if they said Please enter a phrase.

09:53.370 --> 09:55.630
But then they just press enter.

09:55.930 --> 09:58.030
And this would still work.

09:58.110 --> 10:00.650
However it would be there would be nothing.

10:00.660 --> 10:04.760
So we want to make sure that doesn't happen.

10:04.770 --> 10:13.260
So we're going to actually get the length of this phrase and check to see if it's zero and if it is

10:13.680 --> 10:21.150
then we're going to print out something and then make sure they do it again.

10:21.570 --> 10:26.000
So what some say to that.

10:26.020 --> 10:34.390
So for this I need this string to be able to get the link that says doing this.

10:34.720 --> 10:44.650
There And here we're going to say have the link.

10:45.270 --> 10:52.180
All right here a link to us for Lion

10:56.320 --> 11:01.210
of secret is

11:04.020 --> 11:15.610
this and so if the link is zero then we're going to output.

11:16.100 --> 11:23.070
Just put something directly here so I'm not going to say it's an input air I'm going to say you must

11:24.920 --> 11:30.560
enter a word that's longer 0 do it's

11:33.230 --> 11:34.120
Please try

11:37.640 --> 11:40.990
this.

11:41.000 --> 11:44.090
And this was failure to this case

11:54.480 --> 11:55.350
and

12:00.920 --> 12:04.720
we should also pass back the link of the secret phrase actually.

12:04.730 --> 12:06.830
So let's actually change this.

12:07.200 --> 12:07.560
It

12:11.640 --> 12:15.350
or know how long it is not to do this every time.

12:16.840 --> 12:18.910
It's just that.

12:19.950 --> 12:20.500
Turn the

12:24.040 --> 12:25.870
we know it has to be greater than zero.

12:25.880 --> 12:29.510
Otherwise it will be looped again.

12:29.570 --> 12:34.820
So that's this one so we need a variable for the length.

12:37.410 --> 12:38.150
Here

12:41.830 --> 12:49.790
secret phrase length is get that from here.

12:51.590 --> 12:55.470
So next we should.

12:55.850 --> 13:05.030
One thing you want to do is actually paste in the functions we made from the array lecture or from the

13:05.030 --> 13:06.230
array practice lecture.

13:06.230 --> 13:18.180
So we had that those two functions called Get character and use these already have them in my clipboard.

13:18.490 --> 13:23.640
So we had these ones of good character which you could have a prompt in error.

13:23.650 --> 13:27.890
These are directly from that array lecture.

13:28.240 --> 13:30.930
I didn't change them in any way.

13:30.970 --> 13:38.230
So if you remember this you can get them at the prompt in the air and it checks to see if it's an alpha

13:38.320 --> 13:39.870
you need to.

13:40.640 --> 13:43.990
And also check to see if it's lower case.

13:46.130 --> 13:52.610
Well this won't really matter too much after we fix this so.

13:53.130 --> 13:58.270
And he could also give the give it's some valid input too.

13:58.410 --> 14:00.140
And like what.

14:00.340 --> 14:08.560
OK so let's we have to include CC type because otherwise it will work clewed

14:10.940 --> 14:15.230
type this way.

14:15.900 --> 14:19.710
And this is just so we have it and can use it.

14:19.710 --> 14:24.050
So for the next one is

14:27.000 --> 14:36.980
hidden word so are hidden phrase hidden phrase because to say make hidden.

14:38.550 --> 14:41.070
We're going to pass the secret phrase

14:43.480 --> 14:50.310
and the secret free.

14:50.420 --> 14:55.650
And this is why I have the secret phrase like just as for this function.

14:56.000 --> 15:02.600
So it's copy this and declare it of

15:08.540 --> 15:15.070
and this will pass back a character pointer of the new memory that we make.

15:16.040 --> 15:20.640
So this would be Comte's shore star

15:24.320 --> 15:25.160
and

15:30.250 --> 15:32.050
it's this

15:40.300 --> 15:44.370
and put it it's and these will be the last.

15:44.570 --> 15:45.890
It's right here.

15:47.270 --> 15:48.780
Make hidden free.

15:48.790 --> 15:49.160
It's

15:53.140 --> 15:53.950
so

15:57.470 --> 15:59.070
do it is.

15:59.300 --> 16:03.950
Let's take a look at the key phrase here.

16:03.960 --> 16:04.170
Right.

16:04.160 --> 16:12.500
So making news E-string given the length of the phrase and then set all the dashes this should exclude

16:12.510 --> 16:14.510
actually the

16:17.740 --> 16:18.780
spaces.

16:18.850 --> 16:21.300
So we haven't taken that into account.

16:21.430 --> 16:26.000
We will in the function itself so this

16:29.370 --> 16:47.910
char star also a hidden phrase called new char secret phrase link was one always plus one seed in all

16:47.920 --> 16:50.500
character.

16:50.730 --> 16:56.520
So it's wrong.

16:56.640 --> 17:09.130
So for int i zero I's less than Lenk secret reads like

17:12.220 --> 17:15.260
Spross.

17:15.460 --> 17:32.360
And so if the secret were a secret phrase is not equal to a space then we will set the hidden or hidden

17:34.440 --> 17:42.000
spell phrase hidden phrase of will be the dash and

17:45.360 --> 17:51.250
otherwise if it is then we'll just kind of set it to be the same thing as in phrase.

17:51.350 --> 17:51.630
I

17:56.500 --> 18:06.460
just say dash or space here Gaelic that and again remember didn't phrase

18:11.320 --> 18:13.650
of the last one.

18:13.780 --> 18:14.380
The secret

18:17.440 --> 18:23.040
fragrance link should be

18:26.780 --> 18:27.700
the null character.

18:27.750 --> 18:28.170
Remember

18:32.880 --> 18:42.410
turn the hidden phrase and in fact in the game you should do instead is a pointer right.

18:47.040 --> 18:47.340
Point

18:50.590 --> 18:52.400
like that because we own it.

18:52.400 --> 18:57.130
So play game owns the hidden phrase memory.

18:57.650 --> 19:07.250
So you have to remember this so we know that we we as in play game has to delete it later.

19:09.090 --> 19:11.190
So what's next.

19:11.220 --> 19:28.080
So now that we have all of that we shifted to rob the poor to using the number of guesses left and the

19:28.080 --> 19:32.050
hidden phrase.

19:32.720 --> 19:41.920
So you're saying Gironde board and we're going to use

19:46.470 --> 19:49.200
yes is laugh.

19:50.560 --> 19:54.580
And you'll see why raising a number of guests is left his second and the

19:57.840 --> 19:58.670
pointer

20:01.190 --> 20:06.180
phrase.

20:06.370 --> 20:07.320
Copy this

20:14.720 --> 20:19.810
peer to set it.

20:24.140 --> 20:32.490
And Sarber venture I think because we're just drawing stuff and there say in here and Charsadda Star

20:32.490 --> 20:34.020
year.

20:34.250 --> 20:43.460
And we don't need the link for this because then we could just use sterling césarine and probably don't

20:43.460 --> 20:45.220
want to change it either.

20:46.140 --> 20:47.040
All right.

20:47.090 --> 20:50.930
So you put Konst year.

20:51.810 --> 20:53.550
So this

21:06.490 --> 21:08.060
and it's

21:11.640 --> 21:12.210
your

21:15.740 --> 21:28.440
like that's so we didn't actually do a top down design for the DRob board at all but we should be able

21:28.440 --> 21:32.260
to easily figure this out right.

21:32.490 --> 21:38.590
So what we want to do is check to see how many guesses we have left.

21:39.600 --> 21:51.660
And then based on that we want to draw the gallows and the guy if there is if it's not six guesses say

21:52.380 --> 21:55.090
so what.

21:55.110 --> 22:03.210
Start doing that and we're going to use a switch statement actually and switch on the number of guesses

22:03.230 --> 22:03.720
lasht

22:08.720 --> 22:15.880
and for this case zero will be

22:19.280 --> 22:20.490
the break.

22:21.020 --> 22:21.600
OK.

22:21.670 --> 22:31.390
So caesura will be they have 0 guesses left so we should draw the entire Gallo's with the guy.

22:31.620 --> 22:36.910
So that so put a space in between.

22:36.920 --> 22:49.120
And there should be three dashes and two different signs that the whole copy what I'm doing.

22:49.160 --> 22:54.960
Hope you're following along anyway.

22:56.370 --> 22:58.270
It's boring to watch.

22:58.270 --> 22:58.680
I think

23:03.130 --> 23:08.820
so for the head to use an Oh.

23:09.150 --> 23:10.610
I don't know maybe a capital

23:13.970 --> 23:14.330
better

23:23.150 --> 23:33.630
body stick that and of course Actually since this is this is going to be the case where we're showing

23:33.690 --> 23:44.370
the whole body of the arm like here and then need two two dashes here because this is the escape character

23:44.430 --> 23:50.540
and we have to escape the arm so it'll actually look like this when it draws but you need to do it like

23:50.620 --> 23:52.310
that.

23:52.530 --> 23:54.900
Just like we have like Dash or slash.

23:54.900 --> 24:02.800
And for a new line we have to do slash slash slash for this backslash.

24:02.990 --> 24:03.260
So

24:09.740 --> 24:11.470
it's just this

24:14.070 --> 24:19.840
and slash slash leg.

24:21.920 --> 24:24.290
Dasch in Los

24:27.070 --> 24:30.290
dash OK.

24:30.410 --> 24:37.210
So we should be copying this whole thing and we have to do this for each case now.

24:37.260 --> 24:42.330
So Case 1 and will remove one part of it.

24:42.440 --> 24:48.990
So remove the leg in this case the leg will be the last thing you see.

24:51.900 --> 24:55.420
Case to

25:05.060 --> 25:06.320
move the

25:09.340 --> 25:16.930
speed the body and the hands her arms case three

25:24.410 --> 25:25.610
it will be

25:27.720 --> 25:32.710
the his left arm is gone.

25:32.910 --> 25:34.410
Here this

25:41.830 --> 25:43.140
is right here.

25:47.130 --> 25:49.580
The key is for

25:58.430 --> 26:05.060
he will remove his other arm which is body that

26:09.390 --> 26:12.570
and Caze five

26:28.470 --> 26:31.800
move the body.

26:31.820 --> 26:36.100
This is the head.

26:36.290 --> 26:37.920
He's 6

26:41.430 --> 26:42.030
ye

26:53.300 --> 26:55.000
yes the gallows

27:00.480 --> 27:02.550
so we understand what's happening here.

27:02.580 --> 27:09.190
We're just switching based off the number of guesses and then we're going to do the output for.

27:09.820 --> 27:13.300
For that value.

27:14.040 --> 27:22.590
That's really it and so it defaults.

27:22.840 --> 27:24.920
Deif all we have nothing.

27:29.710 --> 27:32.550
And we should also output it's

27:36.130 --> 27:41.710
we should also have to analyze here.

27:41.970 --> 27:47.360
Actually we want another space after Jawan

27:54.720 --> 27:57.190
you don't have to use just kind of a formatting thing.

27:58.570 --> 27:58.830
I'm going

28:16.770 --> 28:18.580
in next

28:21.150 --> 28:21.700
mishit.

28:21.720 --> 28:24.110
I put the secret word here secret phrase

28:29.460 --> 28:31.200
or hidden phrase.

28:31.240 --> 28:33.610
Yes.

28:36.510 --> 28:37.110
Pointer

28:39.930 --> 28:41.340
is like that.

28:43.130 --> 28:47.150
And again on two different ch or two and those.
