Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Practice Java Objects - Word Guessing Game!
You have completed Practice Java Objects - Word Guessing Game!
Preview
Let's use method overloading to accept a String as well as a char for our guess.
This video doesn't have any notes.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
out of the input blows up
because there's no character there.
0:00
We could fix this in the prompter class,
but other code using our game
0:01
class will likely need
the same functionality.
0:04
To prevent code duplication
and keep things dry, don't repeat
0:07
yourself, let's have our game accept
a string as well as a character.
0:11
Hey, why don't we use that
method signature trick
0:15
to allow our apply
guess to accept a string as well?
0:18
So we'll add a new method
with the same name,
0:23
apply guess, but it will expect a string
for its parameter.
0:25
So there will actually be two different
methods, one that takes a string
0:29
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up