This is what I have so far but I am not familiar with pseudocode:
Include headers
Variables
Begin
Display the rules
Prompt users for their names
Ask if they want to play
Ask them for their choice of objects
Determine the winner
Ask if they would like to play again
Valid selection
if selection is ‘R’ or ‘r’ or ‘S’ or ‘s’ or ‘P’ or ‘p’, then it is a valid selection;
otherwise it is invalid
Converting enumeration types (input)
if selection is ‘R’ or ‘r’
return Rock;
if selection is ‘P’ or ‘p’
return Paper;
if selection is ‘S’ or ‘s’
return Scissors;
Converting enumeration types (output)
if object is ROCK
output “Rock”
if object is PAPER
output “Paper”
if object is SCISSORS
output “Scissors”
The winning object
if one player chooses rock and the other chooses Scissors
rock wins
if one player chooses rock and the other chooses paper
paper wins
if one player chooses scissors and the other chooses paper
scissors win
The game results
a. If player1 and player2 have the same selection, it is a tie game
b. Else
{
1. Determine the winning object. (Call function winningObject)
2. Output each players choice
3. Determine the winning player
4. Display the winning player
}
Thank players for playing
Pseudocode is completely divorced from any language, though it is often couched in some language’s syntax.
The purpose of pseudocode is to think through an algorithm in plain English*, using minimal syntax to structure flow control.
You have a good start. Get rid of all the language-pedantic stuff like “include headers” and “variables” and so on.
“Display the rules” is a good one, etc.
No need to be really specific on types of things or values except when it makes a difference. Hence, you could simply say, “if selection is ‘rock’”. The actual input values are not significant at this point — as long as the user inputs something that the final program will accept as ‘rock’ you are good.
You do not typically need line numbers or lettering unless you intend to refer to that line somewhere else. (Labels are only needed for “goto” statements, which you can entirely avoid.)
Hope this helps some.
* English is the common language for programming, but you can certainly write your pseudocode in whatever language is most convenient to you and / or your readers.
The purpose is understanding an algorithm; not parsing a language.
Thank you guys for replying, I am not sure whether that last guy is correct in saying that it is not pseudocode.
Display the rules
Prompt users for their names
Ask if they want to play
Ask them for their choice of objects
Determine the winner
Ask if they would like to play again
Valid selection
if selection is ‘R’ or ‘r’ or ‘S’ or ‘s’ or ‘P’ or ‘p’, then it is a valid selection;
otherwise it is invalid
Converting enumeration types (input)
if selection is ‘R’ or ‘r’
return Rock;
if selection is ‘P’ or ‘p’
return Paper;
if selection is ‘S’ or ‘s’
return Scissors;
Converting enumeration types (output)
if object is ROCK
output “Rock”
if object is PAPER
output “Paper”
if object is SCISSORS
output “Scissors”
The winning object
if one player chooses rock and the other chooses Scissors
rock wins
if one player chooses rock and the other chooses paper
paper wins
if one player chooses scissors and the other chooses paper
scissors win
The game results
a. If player1 and player2 have the same selection, it is a tie game
b. Else
{
1. Determine the winning object. (Call function winningObject)
2. Output each players choice
3. Determine the winning player
4. Display the winning player
}
Thank players for playing
Above is the pseudocode I have edited it down to. Everything from Valid Selection to "4. Display the winning player}" is from my c++ textbook. i am more confused about the rest that I added. Any other suggestions about my code before I submit it?
No, abdulbadii was not correct.
I didn’t report him, though.
Your entire thing is still very long, repeating itself three times.
Forget “pseudocode” for a second. Just write out, in the simplest possible terms, how to play a game of rock-paper-scissors. You shouldn’t need more than 5 or 6 lines of English for that.