Answered step by step
Verified Expert Solution
Question
1 Approved Answer
CS 5 2 : C + + Programming Project 2 : Superhero combat Due: 1 1 : 5 9 pm , 5 / 2 4
CS : C Programming
Project : Superhero combat
Due: : pm
Goal
Finishing the functionality introduced in Homework you'll implement fights that can occur between Hero objects. There won't be any functionality removed only added.
Setup
The GitHub classroom link is posted on Canvas.
Be sure to follow the setup guide on Canvas.
You should read this writeup in its entirety before writing any code. There is more direction in this write up than there will be for later assignments.
Because this assignment adds onto homework all notes that apply to homework apply to this homework.
This assignment introduces a new pair of files: powers.h and powers.cpp These files will contain several class definitions.
While this assignment has a "heroes.txt file, we will not be testing with this file. Make sure your code can handle a different input file.
Your program will interact with the user to allow heroes to fight against each other. Once heroes are selected, a random power from each hero will be selected and the results of the two powers fighting will determine who wins each round.
The winner of each round is determined by this grid:
tableFGI,LNSFGFLFFGGI,GGSIFI,,LI,ILLGLLSNFGI,LSSFSI,SS
Power Definitions:
F: Flight
G: Gadgets
I: Intelligence
L: Lasers
: Nationalism
S: Strength
All functions you're to complete are currently stubs they have just enough code for the program to compile and run though the results aren't correct. Several places there are TODO comments this is where we recommend you fill in your code. We recommend that you fill in the functions in the order below.
While all of the cpp files are stubbed out, you should use your code from homework for the functions in places like strlib.cpp
File "powers.cpp
Note the header file it's well documented and a good indication of what each function needs to do Do not change the function declarations in this file that also means you should not change the function inputs or outputs in the implementation file You may add any additional functions you need.
The header file contains...
An enum with identifiers for the different powers.
An abstract class Power that is a base class for the other powers.
Six power classes that inherit from Power.
A powerFactory function that generates powers from an inputted string.
The implementation file only has functions for the Power class and the powerFactory. You are to create the functions for all of the individual power classes. The needed functions can be found in the header file.
The Power class has member variables, they are:
The mDescription contains a string set in the child classes. The value is set in the individual power constructors. This is the value that will be displayed when the power is listed for the hero. You may fill in whatever value you want just make sure it conveys the information about the power. For example, FlightPower might set the mDescription to "Can shoot lasers" or GadgetPower may set it to "Uses some crazy gadgets" Keep the description to a single line of text no more than characters There are points of extra credit available for humorous or amusing text here but it must stay PG rated.
The mPowerID is the POWERID enum value corresponding to the appropriate power. This should also be set in the child class constructors.
The Power class has functions you must complete
The getID function should return an enum value from the header file. That value mPower ID should be set in the individual power constructors.
The stream operator operator should send the power's description mDescription to the inputted stream. That value should be set in the individual power constructors.
The Power class has pure virtual functions that the child classes must implement.
The use function will return a string that will be displayed when the power is used.
The fight function return an integer with the results of the fight from the previous table. The possible values are
if the current Power wins
in the event of a tie
if the current Power loses
Each power has functions to complete. They are
The constructor, which must set the member variables from the base class.
The use function returns a string that will be displayed when the heroes fight each other. You may return any text you'd like. For example LaserPower might return "shoots lasers from their eyes. PEWPEWPEW!" while StrengthPower might return "SMASH!!".
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 whic
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started