Question: Implement the RPS game (Rock, Paper, Scissors) Rock breaks Scissors Paper covers Rock Scissors cuts Paper Player class Private member variable int choice 1: Rock

Implement the RPS game (Rock, Paper, Scissors)

Rock breaks Scissors

Paper covers Rock

Scissors cuts Paper

Player class

Private member variable int choice

1: Rock

2: Paper

3: Scissor

function play()

HumanPlayer class

Inherits Player

Redefine play() function

Ask user for input

Input can be R, P, S for Rock, Paper, Scissor

Convert input to number and store in choice variable

ComputerPlayer class

Inherits Player

Redefine play() function

Generate random number between 1 and 3 (inclusive)

void determineWinner(Player &a, Player &b) { //Although this is not recommended, you don't have to put Player as const for this exercise Call a.play(); Call b.play(); Logic to compare choice of a and b and determine who won Print out a message for the winner } 
int main() { srand(1); Computer comp; Human human; determineWinner(human, comp); determineWinner(comp, comp); } 

Implement the RPS game (Rock, Paper, Scissors) Rock breaks Scissors Paper covers

include kiostream 2 #include using namespace std; 5 class Player 6 private int choice; 10 class Human 11 LI; 12 13 class Computer 14 L); 15 16 void determine Winner (Player &a, Player& b) int c1 a play 17 int c2 b.play 19 20 L) 21 22 int main grand (1) Computer comp 25 Human human; 26 determine Winner (human, comp) 27 determine Winner (comp comp) 28 29

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!