Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I was given this code for guidance but it does not work it says that the rs are not being used I have tried to

I was given this code for guidance but it does not work it says that the rs are not being used I have tried to figure it out but it doesnt work. C++ MUST BE USED. Thank you
image text in transcribed
image text in transcribed
image text in transcribed
Details: You are tasked with (pseudo)-randomly assigning roles to a group of 5 players that are playing a sci-fi/fantasy game. Each player will be assigned one of four available roles. There is a possibility that some roles may be filled by more than one player and that some roles may be unused Implementation Each player is represented as a variable of the enumeration type role role player5; //sample declaration of variable player5 of type role Enum types will be discussed during lecture; see Savitch 119 120 for additional details. The constants for role are BITBARD BYTE BRAWLER, DATA MAGE TECH_KNIGHT You will define two (2) functions for this assignment: assignRoles) has five parameters of role enum type, one for each player. This function randomly assigns a role constant to each player. This is a void function; if it helps, one can say that it returns five values. getRoleName0 has one parameter of role enum type. This function outputs a string literal that represents that role. To illustrate, the constant DATA MAGE stored in the role parameter will be used to output the string literal "Data Mage". Here are the string-type role names for each role-type constant: BIT BARD -> "Bit Bard BYTE BRAWLER -> "Byte Brawler" DATA MAGE-> "Data Mage" TECH_KNIGHT-> "Tech Knight" You may use the selection statement(s) of your choice in this function (i.e. if/if-else, switch) main) must be used exclusively to: e declare five role variables call assignRoles0 once . call getRoleName0 five times . output results Results: You will output the roles assigned to each player in the following format: Player 1: [Role] Player 2: [Role] Player 3: [Role] Player 4: [Role] Player 5: [Role] Where [Role] is the randomly-assigned role for each player #include #Include #Include using namespace std; Declare enum enum role { BIT-BARD =0, BYTE-BRAWLERz1, DATA-MAGE=2, TECH-KNIGHT-3); This function assigns role to 5 enums vold assignRole(role ri, role r2, role r3, role r4, role r5) Wrand) glves a random Integer. Uing %5 generates Integer between 0 and 4 r2 rolelrand()% 5); 13-role rand()%5); r4-role(rando%5; rs-role rand()%5); This function retuns string name of an enum value string getRolerole r) Ifr BIT_BARD) return "Bit Bard" lftr == BYTE-BRAWLER) f(r DATA-MAGE) else return "Byte Brawler return "Data Mage return "Tech Knight; Int main( wUse srand with a seed to get different random numbers sranditime()); //Here time(0) Is seed role r[5l; N5 enums WAssign roles to 5 players asslgnRole(rlo, ri], r[21, r[3], r[4l &Print roles for(Int I 0; K5; +-)

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

Database Systems An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

More Books

Students also viewed these Databases questions

Question

5. How would you describe your typical day at work?

Answered: 1 week ago

Question

7. What qualities do you see as necessary for your line of work?

Answered: 1 week ago