comp.lang.ada
 help / color / mirror / Atom feed
From: Marin David Condic <mcondic.nospam@acm.org>
Subject: Re: I need advice please on this Ada95 hangman game
Date: Sun, 31 Dec 2000 10:48:13 -0500
Date: 2000-12-31T15:47:46+00:00	[thread overview]
Message-ID: <3A4F553C.D5687CEB@acm.org> (raw)
In-Reply-To: 92l6ip$itm$1@nnrp1.deja.com

Ted Dennison wrote:

> In article <t4s3dn60cip62b@corp.supernews.co.uk>,
>   "Mark Pagdin" <mark_pagdin@lineone.net> wrote:
>
> > This is my first programming language and obviously I am finding it
> > hard to learn it. However I have been set a project to create a
> > program to play hangman (a word game).
> ...

> I can see several ways of accomplishing that task. Which approach you
> take boils down to how you want to encode a "guess", and what data
> structure you use to store them all.
>

It might help to sort of "visualize" the problem. Picture the game show
"Wheel Of Fortune" (Essentially "hangman" with lots of flashing lights and
prizes.) We have Vanna White turning around letters displayed on a board. On
the screen below are a list of letters that were incorrect guesses. The
board that Ms. White is working at is essentially a blank string that she
fills in with characters if they match some position in the non-visible
string that holds the phrase being guessed. There is yet another string that
is holding characters that were guessed, but didn't match anything in the
invisible phrase.

So basically, what you need is a string that holds the phrase to be guessed.
Then you need a string of identical size that is initially blank to hold the
characters that were correct guesses and is filled in with the guessed
character in the matching position from the key phrase. Finally, you need a
string that holds incorrect guesses where the size of the string is the
maximum number of allowed wrong guesses.

From there, its just a matter of collecting up the guess from the user,
scanning to see if it is in the key phrase and if it is, you put it in the
displayed partial phrase. Otherwise, you put it in the incorrect guess
string. After that - just display the whole mess for the user.

This should be helpful without actually doing the assignment for you. What
you're trying to learn here is how to clearly understand the real world
problem and figure out a way to model that in a computer program. At the
intro-programming course level, you have to first struggle to understand the
mechanics of the programming language and that can be hard enough. But the
ultimate goal is to understand problem solving.

Hope you get it running from here.

MDC
--
======================================================================
Marin David Condic - Quadrus Corporation - http://www.quadruscorp.com/
Send Replies To: m c o n d i c @ q u a d r u s c o r p . c o m
Visit my web site at:  http://www.mcondic.com/

    "Giving money and power to Government is like giving whiskey
    and car keys to teenage boys."

        --   P. J. O'Rourke
======================================================================





  reply	other threads:[~2000-12-31 15:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-12-30 16:30 I need advice please on this Ada95 hangman game Mark Pagdin
2000-12-30 17:12 ` Bruce or Tracy
2000-12-30 17:53   ` Ted Dennison
2000-12-30 17:27 ` Robert Dewar
2000-12-30 17:31 ` Robert Dewar
2000-12-30 17:38 ` Ted Dennison
2000-12-31 15:48   ` Marin David Condic [this message]
2001-01-07  1:16 ` John English
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox