Rock Paper Scissors

#include <iostream>
#include <string>
#include <ctime>

using namespace std;

// Global variables

enum Choice { ROCK, PAPER, SCISSORS} ;


int myWin = 0;
int youWin = 0 ;
int total = 0 ;

Choice player_choice ;
Choice computer_choice;
string name[] = { "Rock", "Paper", "Scissors"};
Choice get_Computer_choice() ;

void decide_winner( ) ;
string get_msg(Choice winner) ;
void summary() ;

int main() {

srand(time(0)) ;
string input;
char c ;

while(true) {

cout << "Enter R for Rock, P for Paper , S for Scissor or E for Exit: ";
cin >> input ;
c = input.at(0) ;

// determine the player's choice

computer_choice = get_Computer_choice() ;


int pc = (int) player_choice ;
int cc = (int) computer_choice ;

cout << "You chose " << name[pc] << " , " << endl ;
cout << " I chose " << name[cc] << " , " << endl ;


decide_winner() ;
}

// print the game summary


sumamry() ;

return 0;

}

Choice ch[] = { ROCK, PAPER, SCISSORS} ;

Choice get_Computer_choice(){
int n = rand() % 3 ;
return ch[n];

}

void decide_winner(){

// determine the winner , print the message, update the counts
}


string get_msg(Choice winner) {



if ( winner == ROCK)
return string("Rock smashes Scissors... ") ;
else if (winner == PAPER )
return string("Paper covers Rock ...") ;
else return string("Scissors cuts Paper...");
}



void summary() {

// print the game summary
}

//I need some help with this coding assignment...any suggestions?



This is what the output should look like:

Enter R for Rock, P for Paper , S for Scissor or E for Exit:P
You chose Paper ,
I chose Rock ,
Paper covers Rock ...YOU WIN!!

Enter R for Rock, P for Paper , S for Scissor or E for Exit: p
You chose Paper ,
I chose Rock ,
Paper covers Rock ...YOU WIN!!

Enter R for Rock, P for Paper , S for Scissor or E for Exit: p
You chose Paper ,
I chose Rock ,
Paper covers Rock ...YOU WIN!!

Enter R for Rock, P for Paper , S for Scissor or E for Exit: r
You chose Rock ,
I chose Paper ,
Paper covers Rock ...I WIN!!

Enter R for Rock, P for Paper , S for Scissor or E for Exit: r
You chose Rock ,
I chose Scissors ,
Rock smashes Scissors... YOU WIN!!

Enter R for Rock, P for Paper , S for Scissor or E for Exit: r
You chose Rock ,
I chose Paper ,
Paper covers Rock ...I WIN!!

Enter R for Rock, P for Paper , S for Scissor or E for Exit: s
You chose Scissors ,
I chose Rock ,
Rock smashes Scissors... I WIN!!

Enter R for Rock, P for Paper , S for Scissor or E for Exit: s
You chose Scissors ,
I chose Scissors ,
Result is a tie.
Enter R for Rock, P for Paper , S for Scissor or E for Exit:s
You chose Scissors ,
I chose Scissors ,
Result is a tie.
Enter R for Rock, P for Paper , S for Scissor or E for Exit: r
You chose Rock ,
I chose Paper ,
Paper covers Rock ...I WIN!!

Enter R for Rock, P for Paper , S for Scissor or E for Exit: s
You chose Scissors ,
I chose Paper ,
Scissors cuts Paper...YOU WIN!!

Enter R for Rock, P for Paper , S for Scissor or E for Exit: p
You chose Paper ,
I chose Rock ,
Paper covers Rock ...YOU WIN!!

Enter R for Rock, P for Paper , S for Scissor or E for Exit: p
You chose Paper ,
I chose Scissors ,
Scissors cuts Paper...I WIN!!

Enter R for Rock, P for Paper , S for Scissor or E for Exit: r
You chose Rock ,
I chose Paper ,
Paper covers Rock ...I WIN!!

Enter R for Rock, P for Paper , S for Scissor or E for Exit: s
You chose Scissors ,
I chose Scissors ,
Result is a tie.
Enter R for Rock, P for Paper , S for Scissor or E for Exit: e

Total number of games played : 15
Number of games you win : 6
Number of games I win : 6
Number of tie games : 3

//I need some help with this coding assignment...any suggestions?


Try not to use infinite loops like while(true)
Topic archived. No new replies allowed.