Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CS 5 2 : C + + Programming Project 2 : Superhero combat Due: 1 1 : 5 9 pm , 5 / 2 4

CS 52: C++ Programming
Project 2: Superhero combat
Due: 11:59 pm,5/24/2024
Goal
Finishing the functionality introduced in Homework 2, 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 2, all notes that apply to homework 2 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 2 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:
\table[[,F,G,I,L,N,S],[F,,G,F,L,F,F],[G,G,,I,G,G,S],[I,F,I,,L,I,I],[L,L,G,L,,L,S],[N,F,G,I,L,,S],[S,F,S,I,S,S,]]
Power Definitions:
F: Flight
G: Gadgets
I: Intelligence
L: Lasers
N : 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 3 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 2 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 80 characters). There are 5 points of extra credit available for humorous or amusing text here - but it must stay PG rated.
The mPowerID is the POWER_ID enum value corresponding to the appropriate power. This should also be set in the child class constructors.
The Power class has 2 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 2 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
1 if the current Power wins
0 in the event of a tie
-1 if the current Power loses
Each power has 3 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 -1,0, and 1. 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 -1. This function should also use COUT to display a line of text indicating whic
image text in transcribed

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

Concepts Of Database Management

Authors: Joy L. Starks, Philip J. Pratt, Mary Z. Last

9th Edition

1337093424, 978-1337093422

More Books

Students also viewed these Databases questions

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago