Programming Forums
User Name Password Register
 

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

Reply
 
Thread Tools Display Modes
Old Mar 12th, 2005, 4:41 PM   #1
Rob.K
Newbie
 
Join Date: Mar 2005
Posts: 4
Rep Power: 0 Rob.K is on a distinguished road
Pseudocode Help

Hi,
Im a computing student and need help with some pseudocode. The following is what I have got so far...

SET point_value = 10
SET suit_value = Hearts
SET point_valueA = suit_valueA = guess_count = game_count = = 0
REPEAT
OUTPUT message to operator for suit_valueA
GET suit_valueA
IF suit_valueA == suit_value THEN
OUTPUT message indicates successful guess
ELSE
OUTPUT message indicates incorrect guess
END IF
UNTIL suit_valueA == suit_value
REPEAT
OUTPUT message to operator for point_valueA
GET point_valueA
IF point_valueA == point_value THEN
OUTPUT messages indicates successful guess
ELSE
IF point_valueA < point_value THEN
OUTPUT message indicates guess to low
ELSE
OUTPUT message indicates guess to high
END IF
END IF
UNTIL point_valueA == point_value

The code is for a game which goes by the following rules...

1) Imagine computer randomly selects a card from a pack of cards.
2) The first player must guess the suit then its value
3) After each guess for the suit a message will display whether the player was correct or not.
4) After each guess for the value a message will display whether the player was correct, too high or too low.
5) The individual game ends when a player has correctly identfied the card, the next player is now given a new card.
6) On completing 3 games each the average number of guesses to correctly identify the card should be displayed for each player.
7) The game should be restricted to three players.

So basically I have completed the first 4 steps but need help editing my code to include rules 5, 6 and 7.

Any help at all would be very much appreciated.

Many Thanks,

Rob.
Rob.K is offline   Reply With Quote
Old Mar 13th, 2005, 2:30 PM   #2
Rob.K
Newbie
 
Join Date: Mar 2005
Posts: 4
Rep Power: 0 Rob.K is on a distinguished road
Anyone out there?
Rob.K is offline   Reply With Quote
Old Mar 15th, 2005, 2:42 AM   #3
xaosai
Newbie
 
xaosai's Avatar
 
Join Date: Mar 2005
Posts: 8
Rep Power: 0 xaosai is on a distinguished road
How you implement the last steps depends on whether or not you want to do it dynamically.

Statically: Write a parent routine that executes 3 games and records the necessary data and displays when completed.

Dynamically: Write a loop that contiues to execute games until prompted for statistics (your global variables like average guesses per game, etc.) or exit. Writing a simple loop structure is usually easier to debug. I'd use a random number generator to assign random values to point_value and suit_value at the beginning of each game.
xaosai 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:56 PM.

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