An that's it.
So you run this
well you can't run it quite yet.
So let's implement.
Want to play again.
And then run it.
See so let's just add it after the game.
All that.
Here
in for one to play.
Ken
are you going to use our
two functions.
You have these two in fact use this function.
So let me copy this I'll add it to the declarations yet.
Two declarations
this
these two get character functions and you're going to use that in want to play again to make it easier.
So remember how it works is we're going to have a Auray it's char.
So here's the one for the valid inputs and the only valid inputs right to have are yes and no y in this
and how we're going to say is your response Z to get character and we're calling the function.
And then we call it with the prompts would you.
Again and yes or no.
And this is the Arab Spring and we actually are defined it above the error string.
And valid inputs and the length of how many got there.
And then all we have to do is a return response equal to it's
so let's actually run this and see what we have so far.
So hello and see it through the gallows and it drew five dashes right and now it's asking see if you
want to play again.
So no.
So now let's actually do the rest of play again.
So we know our draw board works.
That's good really help and it's just implement the rest of the game.
So while not is over in to the number of guesses laughs and the hidden phrase
dher
raise and the length and I'm going to pass the secret phrase like well just to not have to call Sterlite
again mostly and just kind of notice that.
Rob Ford.
There should be no pointer.
This guy doesn't own it.
So that's copying pasting things or is bad usually.
So try not try to avoid it if you can cause bad things will happen and so should be no pointer for hidden
phrase in draw the draw board.
So
let's just skip implementing this for now and just get the rest of the stuff we'll get the guest guess
is just a character right.
So get the gas and to do that we will
have this gas function improvement
and the other one is the update board I'm just following our top down design right now I'm not implementing
anything and passing the gas and the hidden phrase
and the secret phrase.
And again I'll pass in the secret.
It's like.
And then I will draw the board.
That's Amber.
Yes is left and the
phrase
so soft implement get gas update board and it came over and let's just round out play games.
Would have to come to it again this way.
So it's an say the secret phrase here and a number of guesses.
What and the last thing we need to do is since we own that pointer we have to delete it.
So pointer hidden goodies like this.
So it's only good for the duration of the game.
You know other words.
So now let's finish all this stuff.
Seltsam might get guess.
So it's going to turn a character.
Will actually be using get character for our get gas function.
Character.
Yes.
Returns nothing.
Copy that.
And let's
in and really care about ordering too much right here.
And it's going to do
is
very simple return get character using that function again these input guests and it takes in the input
air strings but are straight.
That's it.
And let's do the date for now.
Even more interesting function.
So it's not going to return anything.
So the guest is a character the changes changes no pointer rank because update or doesn't own it and
you can change it so it should just be a char a star.
This and the secret phrase is a character attracted me to a concert.
This never changes either.
That
and Lanc and we're actually missing something the number of guests is left and that will be a reference
Amber guesses less as we can update the number of guesses left and it will change our callers version.
And that's why it's that reference so it's copy this
here and still pass in the number of guesses left.
And so put it right here.
OK.
So date the board.
So how did we do this so we're basically just looking to see if we found a letter or we found the guess
in the secret phrase.
Right.
And if we did we reveal the that letter and each position of the hidden phrase.
What we didn't do here is to see if because since like an uppercase H is not the same as a lowercase
H we have to ignore case here.
So we're going to ignore the case of the secret phrase.
So we're actually going to make this to lower because our guess is also in lowercase so that and in
fact what we should do here instead is actually say secret phrase.
Because what if they typed in.
Hello right or and high like this.
OK that's a secret phrase.
So if they typed in h it should match h this H which is uppercase and this H.
And if we said it to the guess it would this would be lowercase which is not correct.
Like this what we want to do is just keep it the same as the secret phrase.
So it's you that so here we're going to say have we found one or no
and we're going to use that for for decrementing the number of guesses later.
So for he goes to zero eyes less than the length of or secret phrase like sorry secret Rhee's Lanc
plus.
And if to lower your secret phrase I call to you the guess.
So if the lower case version of the secret phrase is current letter is the same as the guess then we
should say hidden or no pointer in phrase eyes equal to the secret phrase.
And that's not to lower of the secret phrase of I.
Because again we want to preserve the case when it's output but not when we check.
And then we have found it true.
And here if we we didn't find it right then we should
subtract one from the number of guesses left
that is update board so we're almost done.
We only have two functions left so we should implement is
to do that now.
So it's over.
Who'll right turns.
Boolean it's over or not the number of guesses left.
So this would just be a copy because you don't need to know or it doesn't need to change it at all.
So this is the conc char star and no pointer rank doesn't own it.
Copy this.
It Right after the oared.
So how do you know if it's over.
So we go through.
So we go through each of the characters in the hidden phrase to see if it's a dash.
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
over.
Right.
So
three here so see bhool has Dasch.
All else for.
So your source then the secret phrase like boss.
If the new pointer didn't phrase is equal to a dash
then we do have ash
and we want to just break out of the loop because now we know the game or at least has a dash so at
least that portion of the game is not over a number of guesses left.
It's 0 or doesn't have a dash and you know is over.
And finally we have the display results
so it's implement that fairly simple.
So it's copy
it won't return anything
and it'll take a constant Shore star.
Number
it's meant that it's so should be pretty much the same as the number guesser version so if the number
guesses length is greater than zero then you got it right.
C-O got it.
The word is
free.
Yes.
Tres
else
didn't you get it.
Free.
It's
so
phrase
so hopefully that makes sense as well.
So I we're basically done written like 500 lines of code Well probably not because of all this
is comments here but let's read this hidden it's so me that will be there.
So say hello everyone.
So we have a nice Remy.
Hello.
Hi.
Each local lowercase So center so nicely we have the dashes of each thing.
So say H.
And notice that it's said or it output a capital H and a lowercase h properly even though we just entered
a lower case H.
That's working.
How right.
Let's guess.
Let's get it wrong.
W o that head.
Say a Q No and say F is the arm say G the other arm and say k
are almost dead.
So let's actually lose this one and that's a B.
So you can get at the phrases.
Hello.
Hi everyone.
OK.
Would you like to play again.
Let's just rerun this.
So we have a clear console and I'll show you an and this time this is it.
Each see all the R Y
II
inch and a.
Got it.
So that's the major implementation of hangman.
We're following along and I went a little bit quickly.
In the next lecture though I want to go over some odds and ends with this game and see if we can do
a little bit more to it and change a little bit more.
So I will see you in the next lecture.