From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1192c1137d7a2b6 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2000-12-31 07:49:31 PST Path: supernews.google.com!sn-xit-02!supernews.com!216.227.56.88.MISMATCH!telocity-west!TELOCITY!news-out.usenetserver.com!newsfeed2.earthlink.net!newsfeed.earthlink.net!news.mindspring.net!not-for-mail From: Marin David Condic Newsgroups: comp.lang.ada Subject: Re: I need advice please on this Ada95 hangman game Date: Sun, 31 Dec 2000 10:48:13 -0500 Organization: Quadrus Corporation Message-ID: <3A4F553C.D5687CEB@acm.org> References: <92l6ip$itm$1@nnrp1.deja.com> NNTP-Posting-Host: d1.56.ba.4e Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Server-Date: 31 Dec 2000 15:47:46 GMT X-Mailer: Mozilla 4.75 [en] (Windows NT 5.0; U) X-Accept-Language: en Xref: supernews.google.com comp.lang.ada:3488 Date: 2000-12-31T15:47:46+00:00 List-Id: Ted Dennison wrote: > In article , > "Mark Pagdin" 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 ======================================================================