SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 304 Weeks Ago, 5 Days Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 29 Nov 2017 My Price 10.00

Inside the header file, create a struct called Monster

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            type string
  • Combat Power     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 or vector 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):

 

{

"Charmander", "Bulbasaur", "Squrtile", "Pidgey", "Pikachu", "Sandshrew", "Zubat", "Mankey", "Abra","Magikarp", "Eevee", "Rattata", "Vulpix", "Scyther", "Jigglypuff", "Geodude", "Onix", "Staryu","Snorlax", "Mewtwo", "Oddish", "Caterpie","Spearow" , "Charizard", "Zapdos"

};

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.Capture.PNGCapture2.PNG

Attachments:

Answers

(5)
Status NEW Posted 29 Nov 2017 11:11 AM My Price 10.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)