Question: The fight function returns an integer indicating which power won ( from above the possible values are - 1 , 0 , and 1 .
The fight function returns an integer indicating which power won from above the possible values are and Based on the calling class and the class passed in you can determine the results. For example, in the fight function for the LaserPower class, if the other power is Strength then the function will return This function should also use COUT to display a line of text indicating which power wins and a description of the fight. For example, when Intelligence goes against Gadgets, the text to COUT might be "INTELLIGENCE WINS The glitch in the gadget is discovered!". Keep the text sent to COUT to a single line of text no more than characters
The powerFactory function accepts a string as input. The string will have any of the powers that may be listed in the input files see the possible strings earlier in this document The function should return a pointer to a new Power that's created on the heap.
You should thoroughly test the code in this file. For example, generate several powers in main to test the functions.
File "hero.cpp
You should move your code from homework into this file. Here we'll only note the new sections.
The two getters getName and getHealth should return the appropriate member variables.
The takeDamage function will decrement the hero's mHealth variable by ;
The resetHealth function will reset the hero's mHealth to the maximum value.
The stream operator operator should display the hero's name and powers. The first line displayed should be the hero's name and the indication of the start of a list to the inputted stream. This line MUST resemble "Superman has the following powers..." for full credit. After that display all of the hero's powers. Indent each power by tab. You should use the stream operator operator to display the powers as well.
For example, the listing for Superman should resemble:
Superman has the following powers...
Superhuman Strength
Ability to fly
Can shoot lasers
File "fight.cpp
You should move your code from homework into this file. Here we'll only note the new sections.
The selectHero function needs the following input:
A vector of Hero pointers full of heroes to select
A string with the prompt to give the user when selecting a hero
The output stream to interact with
The input stream to interact with
The function displays the prompt to the output stream and receives input with the input stream The user will select the first hero and the second hero to fight. It will return the pointer to the hero at the appropriate index. The first valid index is
Page of
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
