Learn Programming in Java

Seaman Letter Guess

<<Previous | ToC | Next >>
 
Vivian Killian provided the basic structure of this program, and we are refining her English before proceeding to Java. Her third line was:
3. Guess a letter

That's rather vague, let's see if we can get more specific. Who's doing the guessing? This is a two-player game, in this case, both players human. The computer is just the scorekeeper. The first player was finished on line 1, everything else is the second player and the computer interacting. The player guesses, and the computer only inputs that guess. Notice that each step of the way, we are converting Vivian's vague third line into something less vague, hopefully by including one or more of the Five Concepts in the table below.

Vivian's fourth line is unnumbered, which is just as well, because it will become several lines before we are done:

If the letter is wrong, draw a body part
How can the computer know if the letter is right or wrong? If you were the first player and doing your own scoring, how would you know? Right, you would just know. Well actually you do some calculation in your mind so fast you probably don't notice that's what you are doing. Unless you have a super memory, when you are playing this game for real and you pick a big obscure word for the other player to guess, you probably need to look through the word one letter at a time to see if that's the letter they guessed. Let's pretend you cannot keep the whole word in your mind all at once, that you are a computer, and you must do this one step at a time. How would you do it? Write it down (in your program) and then turn the page.
Five Basic Concepts
Sequence
Iteration
Conditional
Variables
Input/Output

  <<Previous | ToC | Next >>

Revised: 2021 June 3