Learn Programming in Java

Seaman Termination

<<Previous | ToC | Next >>

You have finished clarifying (in English) all of Vivian's basic structure of this program, but there is something she left out. Can you figure out what it is? (Hint: Who won?)

How do you know who won in Seaman? Normally the person who thought up the word draws one body part on the seaman for every wrong guess by the other person. If the word is correctly guessed (and fully spelled out with no dashes) before the seaman standing on the boat is fully drawn, then the guessor wins. If the unlucky seaman is fully drawn first, then the person who thought of the word wins.

There are six standard body parts (head, spine, left and right legs, left and right arms), but the boat itself is usually predrawn. Perhaps you could add another four free guesses by drawing hands and feet. So (depending on how many parts you decide to draw) there are anywhere from six to thirteen chances to guess the word. The other player can also make it harder or easier by the size of word they choose.

As I said earlier, drawing body parts using "ASCII Graphics" is a little tricky, so for now you should just keep a numerical score. Tomorrow (or later today) you can actually draw the body parts. But let's make it work first.

The other half of the question is, "How do you know when the word is full spelled out? Real people (not computers) can look at the word with dashes and letters, and see at a glance when all the dashes are gone, or even when there are only one or two left. I am told that the human mind can take in numbers up to five without counting -- I'm not sure about five, I usually group them into two and three, which isn't the same -- but some aboriginal tribal languages have only one word in their language for numbers greater than five: "many." I often use the same word in English ("zillion" = an unspecified large number). The point is, humans don't need to count to know whether there are any dashes left but the computer must count -- at least up to one, as we did in determining whether the guessed letter is in the word or not.

There are several ways the computer can perform this count. Obviously you could make a separate loop to count remaining dashes. By now you probably figured you can also count them in the same loop that is searching for a match and that is replacing dashes with letters. There's another way the computer can know the dashes are gone without counting. Can you think of what that is? (Hint: you already know how long the word is, and you already know when a dash is removed).

Choose some way for your program to know when the game is over, then write that design (in English) into the entry panel, and then turn the page. Don't forget to make sure your loops are all properly closed.

Five Basic Concepts
Sequence
Iteration
Conditional
Variables
Input/Output

  <<Previous | ToC | Next >>

Revised: 2021 June 3