I need help on this, i'm not sure where to begin and need examples on how to set up, thank you.
HEADER FILE:
Create a .h header file 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
Keep this file in your project. DO NOT UPLOAD THE HEADER FILE. I ONLY WANT YOUR .cpp FILE!
MAIN SOURCE FILE:
Write the following functions:
captureAttempt()
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 combatPower 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 if it is equal to zero. If it is, you caught the pokemon so return true. If it is any other number, you did not catch the pokemon. The greater the combat power, the slimmer chance that zero appears.
main()
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 pokeballs 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 captureAttempt() function and assign its return to didCatch. Check didCatch to see if the user caught the pokemon and if the user did cout "Gotcha! You caught the monster name!". else, the user did not catch the pokemon and you should cout " broke free! 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.
setMonster()
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 randomNameGenerator() 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.
randomNameGenerator()
Variables:
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 “srand(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.
I need help on this, i'm not sure where to begin and need examples on how to set up, thank you.
HEADER FILE:
Create a .h header file named Monster <-- *** I'd start here ***
Inside the header file, create a struct called Monster
Monster should have the following attributes:
Name //of type string
Combat Power //of type int
Keep this file in your project. DO NOT UPLOAD THE HEADER FILE. I ONLY WANT YOUR .cpp FILE!