Thread: rock paper scissors.. other choices.

  1. #1
    Registered User helloalyssa's Avatar
    Join Date
    Sep 2010
    Posts
    25

    rock paper scissors.. other choices.

    i'm currently writing a rock paper scissors program. our output should look like the following:

    Code:
    bash-2.04$ a.out
    Player One, please enter your move: ('P' for Paper, 'R' for Rock, 'S' for Scissor) r
    Player Two, please enter your move: ('P' for Paper, 'R' for Rock, 'S' for Scissor) p
    Player 2 wins: Paper covers Rock!
    
    bash-2.04$ a.out
    Player One, please enter your move: ('P' for Paper, 'R' for Rock, 'S' for Scissor) S
    Player Two, please enter your move: ('P' for Paper, 'R' for Rock, 'S' for Scissor) r
    Player 2 wins: Rock breaks Scissors!
    
    bash-2.04$ a.out
    Player One, please enter your move: ('P' for Paper, 'R' for Rock, 'S' for Scissor) p
    Player Two, please enter your move: ('P' for Paper, 'R' for Rock, 'S' for Scissor) S
    Player 2 wins: Scissors cut Paper!!
    
    bash-2.04$ a.out
    Player One, please enter your move: ('P' for Paper, 'R' for Rock, 'S' for Scissor) r
    Player Two, please enter your move: ('P' for Paper, 'R' for Rock, 'S' for Scissor) x
    Player 2 has entered an invalid move.
    
    bash-2.04$ a.out
    Player One, please enter your move: ('P' for Paper, 'R' for Rock, 'S' for Scissor) w
    Player Two, please enter your move: ('P' for Paper, 'R' for Rock, 'S' for Scissor) r
    Player 1 has entered an invalid move.
    
    bash-2.04$ a.out
    Player One, please enter your move: ('P' for Paper, 'R' for Rock, 'S' for Scissor) r
    Player Two, please enter your move: ('P' for Paper, 'R' for Rock, 'S' for Scissor) R
    Tie with Rock!
    
    bash-2.04$ a.out
    Player One, please enter your move: ('P' for Paper, 'R' for Rock, 'S' for Scissor) P
    Player Two, please enter your move: ('P' for Paper, 'R' for Rock, 'S' for Scissor) P
    Tie with Paper!

    i've gotten all of them except for the invalid inputs. i know i can't just make an if statement (if (player1 == 'r' && player2 == 'x') for it because it should be for any invalid input. what should i use to invalidate any other letters besides R, P or S?

  2. #2
    Banned ಠ_ಠ's Avatar
    Join Date
    Mar 2009
    Posts
    687
    if you structure your logic the right way all invalid inputs will fall into the else block
    ╔╗╔══╦╗
    ║║║╔╗║║
    ║╚╣╚╝║╚╗
    ╚═╩══╩═╝

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. rock paper Scissors
    By jackstify in forum C++ Programming
    Replies: 3
    Last Post: 12-14-2007, 10:16 PM
  2. Rock Paper Scissors Game
    By tbca in forum C++ Programming
    Replies: 12
    Last Post: 07-09-2007, 12:16 PM
  3. need help with rock paper scissors program
    By Mshock in forum C Programming
    Replies: 3
    Last Post: 04-22-2006, 07:44 AM
  4. Another rock paper scissor question
    By mattflick in forum C Programming
    Replies: 11
    Last Post: 09-29-2005, 09:41 PM
  5. PRS Help
    By SpudNuts in forum C Programming
    Replies: 10
    Last Post: 08-07-2005, 01:14 PM