Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Answer in C++ please. Create a struct named Monster inside the header file-create a struct called Monster Monster should have the following attributes: Name//of type

image text in transcribedAnswer in C++ please.
Create a struct named Monster inside the header file-create a struct called Monster Monster should have the following attributes: Name//of type string Combat Power//of type int Write the following functions: Variables: chance of type int This function takes a Monster data type as an argument and returns a boolean true or false. The monster argument is to use the combat Power value to determine the chance of catching the pokemon. The chances of catching a pokemon depends upon how high the combatPower is. Use the following scale: If combatPower is less than 100, there is a 1 in 2 chance to capture If combatPower is greater than 99, there is a 1 in 4 chance to capture If combatPower is greater than 200, there is a 1 in 8 chance to capture Check the variable "chance" to see it is equal to zero. If it is, you caught the pokemon so return true. lf it is any other number, you did not catch the pokemon. The greater the combat power: the slimmer chance that zero appears. Variables: monster of type Monster input of type char didCatch of type bool initialized and assigned to false: pokeballs of type int initialized and assigned to 5 This is your required starting function, Inside main, you will create an instance of Monster called "monster". Do not initialize the monster variable. On the next line, call setMonster() and assign it to monster. This function will go and populate name and combat power into the instance of monster. Main should contain a loop that checks to see if we did not catch a pokemon and we have at least 1 pokeball available. Inside the loop, cout to the user how many pokebals they have remaining and ask if the user wants to attempt to capture with possible options. Be sure to take one pokeball away for each attempt to capture the pokemon. Call and use the capture Attempt() function and assign its return to didCatch. Check didCatch to see if the user caught the pokemon and if the user did cout "Gotchal You caught the monster name", else, the user did not catch the pokemon and you should cout "broke Attempt to catch again?" If the user did not choose to attempt to catch the pokemon, cout "Got away safely" and quit the program. If the user does not have enough pokeballs, cout "You do not have any pokeballs. so you ran and got away safely", And end the program This function takes the Monster variable passed and will assign the monster's name to the name property in the Monster struct. This is done by calling. random Name Generator () and assigning the function's string return to the monster's name The monster's combatPower is assigned as a random number between 1-450. When these two properties are assigned, return the entire instance of monster with a return statement. An array of names of type string initialized to a constant 25 elements and the following string list (feel free to copy and paste this list below into your code): { }: This function returns a string. It starts by seeding the random number generator with strand(time NULL) and declare an array of type string called "names" set to 25 elements initialized with the above list. It will then randomly return an element containing a string, so that each time this function is called a random pokemon name appears. Please return a random number using "rand()" from 0-24 inside the element to return, which is a string. This function should be called from "setMonster()" to set the monster's name

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

Big Data, Mining, And Analytics Components Of Strategic Decision Making

Authors: Stephan Kudyba

1st Edition

1466568704, 9781466568709

More Books

Students also viewed these Databases questions

Question

What are you afraid of?

Answered: 1 week ago