I combined Yuki wins conditions in an if block. And added Ando wins condition in the else if block.
I do this:
- set the winner to be Ando
- if it’s a tie then set the winner to be tie
- else if <yuki win combo 1> then set the winner to be Yuki
- else if <yuki win combo 2> then set the winner to be Yuki
- else if <yuki win combo 3> then set the winner to be Yuki
I didn’t want a very long condition, so I split it into 3 else blocks.
That makes a lot of sense. Idk why but I chose tie as the default value of winner. Then wrote two really big if else if statements.
I think that’s a natural thing to choose because you’re thinking about the various winning combinations.
@Phil please don’t share your code unless asked. You should learn about pseudocode and use it to describe your solution. You can find a guide here or find more resources.
OK, sorry ![]()
And thanks for the link!
It’s ok to share code in this section, just please use spoilers and codeblocks. See the category page for details: About the Discussion Your Solutions category
Here’s a pseudocode version:
// This program will determine the winner
// of a game of Rock, Paper, Scissors.
INPUT get Ando's choice
STORE Ando's choice in the andoChoice variable
INPUT get Yuki's choice
STORE Yuki's choice in the yukiChoice variable
IF andoChoice = yukiChoice THEN
OUTPUT 'tie'
ELSE IF andoChoice = 'rock' AND yukiChoice = 'scissors' OR
andoChoice = 'paper' AND yukiChoice = 'rock' OR
andoChoice = 'scissors' AND yukiChoice = 'paper'
OUTPUT 'Ando'
ELSE
OUTPUT 'Yuki'
I used this guide from BBC Bitesize to help with the pseudocode.