Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program needs to be in C++ Please use the code below and modify it Code to use: #include enum RPS{ Rock, Paper, Scissors }; //

Program needs to be in C++

Please use the code below and modify it

image text in transcribed

image text in transcribed

Code to use:

#include

enum RPS{ Rock, Paper, Scissors }; // Rock = 1, Paper = 2, Scissors = 3;

class RPS_player_c{ protected: std::string name; public: // create a pure virtual "turn" function std::string getName(){return name;} };

class userPlayer_c /* derived class of RPS_player_c */{

public: int turn(){ // The user will put in a 0 for Rock, 1 for Paper, and 2 for Scissors // Don't let the value be anything other than 0, 1, or 2 } userPlayer_c(std::string name){this->name = name;}

};

class compPlayer_c : public RPS_player_c{

public: int turn(){ // Computer will choose randomly between 0, 1, or 2 } compPlayer_c(){this->name = "Computer";} };

int main(){

// Create two objects, one of each // Must use an array and pointers int another = 1; int winner = 0; do{ // User and Computer need to take a turn/throw if(userThrow == compThrow){ std::cout > another; }while(another);

return 0; }

1 2 E/ /********** This program is meant to produce a Rock Paper Scissors game. A base player of a name, a getName, and a pure virtual turn function needs to be created. 3 Refer below to beginning a base class and main. You will need to make derived classes and fill what is needed. 4 5 6 **********/ 7 8 #include 9 enum RPS{ Rock, Paper, Scissors }; // Rock = 1, Paper = 2, Scissors = 3; class RPS_player_c{ protected: std::string name; public: // create a pure virtual "turn" function std::string getName(){return name; } }; class userPlayer_c /* derived class of RPS_player_c */{ 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 public: int turn() { // The user will put in a o for Rock, 1 for Paper, and 2 for Scissors // Don't let the value be anything other than 0, 1, or 2 } userPlayer_c(std::string name){this->name = name;} }; Sclass compPlayer_c : public RPS_player_c{ public: int turn() { // Computer will choose randomly between 0, 1, or 2 } compPlayer_c(){this->name = "Computer";} }; Gint main() { 40 41 42 43 44 // Create two objects, one of each // Must use an array and pointers int another = 1; int winner = 0; do{ // User and Computer need to take a turn/throw == 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 if(userThrow comp Throw) { std::cout > another; }while(another); 64 65 66 67 return

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

9th Edition

B01JXPZ7AK, 9780805360479

More Books

Students also viewed these Databases questions