Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 22nd, 2005, 8:40 AM   #1
Hass
Newbie
 
Join Date: Nov 2005
Posts: 3
Rep Power: 0 Hass is on a distinguished road
Pseudocode

Dear Members


Can anyone help me with some pseudocode please? It is for a programme called hangman and eventually will be programed in Java!

The hangman program has to hold words between 6-10 letters and the hangman pieces are made up of 9 parts!

Here is my pseudocode so far.


Player one Gets word.

Set word 6 >= 10 letters.
Set Hangman_piece = 9
Set word_marker to length of word
Set guess_count = 0
While (guess_count <= 9) Do

Prompt player two with word.

Player two guesses letter in word.

If letter in word = True Then

Output letter in word marker.

Increment correct guess count +1

Elseif

letter in word = False

Output screen message letter not in word.

Increment incorrect guess count +1

Assemble hangman piece.

EndIf
Enddo

If (guess count > 9) Then

Display game over!

Display all pieces of hangman

Endif

End
Hass is offline   Reply With Quote
Old Nov 22nd, 2005, 8:49 AM   #2
Polyphemus_
Expert Programmer
 
Polyphemus_'s Avatar
 
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4 Polyphemus_ is on a distinguished road
Please be more clear: what do you want to add?
Polyphemus_ is offline   Reply With Quote
Old Nov 22nd, 2005, 8:58 AM   #3
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Quote:
6 >= 10
Prolly evaluate to false. Pseudocode is a good start, read your own as an expression of human thought processes being mapped to the procedural nature of the solution. Actually READ your own and mentally try out the steps. The key is in making decisions and altering the future (or repeating the past).
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Nov 22nd, 2005, 9:58 AM   #4
Lich
Professional Programmer
 
Lich's Avatar
 
Join Date: May 2005
Location: Detroit
Posts: 254
Rep Power: 4 Lich is on a distinguished road
Send a message via AIM to Lich Send a message via MSN to Lich
Quote:
Originally Posted by DaWei
Prolly evaluate to false. Pseudocode is a good start, read your own as an expression of human thought processes being mapped to the procedural nature of the solution. Actually READ your own and mentally try out the steps. The key is in making decisions and altering the future (or repeating the past).
So true. The whole point of pseudocode is to play computer and test your algorithms for logic errors before you actually start writing code.
__________________
--John Cruz
Web Developer
www.cruzweb.net
Lich is offline   Reply With Quote
Old Nov 22nd, 2005, 11:18 AM   #5
Hass
Newbie
 
Join Date: Nov 2005
Posts: 3
Rep Power: 0 Hass is on a distinguished road
I want the Pseudocode to show, when player 2 guesses a letter in the word, to show them if the letter is in that word. If it isnt then I want it to show that if the letter is incorrectly guessed, then part of the hangman will be displayed. I want some kind of loop so that player 2 can guess the letters in the word. The hangman pieces are made up of 9 bits so therefore, player 2 has only got 9 guesses to guess the word.

I am very new to pseudocode and not sure whether what ive done is correct.

:o
Hass is offline   Reply With Quote
Old Nov 22nd, 2005, 11:38 AM   #6
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Pseudocode is not a syntactically constrained thing. Pseudocode is an expression of your thoughts. Here is an example:
Quote:
I want the Pseudocode to show, when player 2 guesses a letter in the word, to show them if the letter is in that word.
Here's another (your words):
Quote:
if the letter is incorrectly guessed, then part of the hangman will be displayed
Don't you see the logic you've already proposed there?
IF the guess is correct
THEN do this
ELSE do that.

Alternatively,
IF the guess is incorrect
THEN do this
ELSE do that.

Now, you go ahead and fill in the "do this" and the "do that", which you've described.
Quote:
show them if the letter is in that word
and
Quote:
part of the hangman will be displayed
You're letting this thing bumfoozle you when you've nearly got it whipped.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Nov 22nd, 2005, 1:18 PM   #7
Hass
Newbie
 
Join Date: Nov 2005
Posts: 3
Rep Power: 0 Hass is on a distinguished road
Thanks for help and comments, I will now have another look at it.
Hass is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:50 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC