Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Must follow specification. Avoid changing the class specification. Avoid modifying the main function provided. Avoid excessively unnecessary steps in algorithms, writing excessively more code than

Must follow specification. Avoid changing the class specification. Avoid modifying the main function provided. Avoid excessively unnecessary steps in algorithms, writing excessively more code than needed, using excessive memory. Use appropriate variable names and whitespace for readability. Write useful comments documenting what is being tested on each test in the main function provided. There are 17 error cases-each one should have a comment. Write useful comments on blocks of code. Write useful comments to describe variables and named constants (be sure to add documentation to main; several variables are created with no comments describing them.) Write a purpose/precondition/post condition for each method you define (you can draw some of this from the specification, but you will need to add anything that is missing.)

Do not use "go to" statements in this argument

Do not use "break" to get out of a loop. Control loops with the loop condition statements/flags instead.

I need help writing the code for the bolded sections. I do not understand how to do that. If you could provide an explanation that would be great but if not I will study this code and use it as an example for others I have to write! Thank you in advance for all your help!image text in transcribed

bool swap_power const string& opname, const Power& newpower); return true; #include #include #include } using namespace std; Fighter::Fighter(/*intentionally empty*/} Fighter::Fighter(string newname, int newattack, int newspeed, int newhealth const vector&newpowers) name(newname), attack newattack), speed(newspeed), healthewhealth), power_vector(newpowers) //*intentionally empty*/ bool Fighterswap_power(int index, const Power& newpower){ /*YOUR DEFINITION GOES HERE/ class Power public: bool Fighter swap_power(const string& opname, const Power& newpower){ /+YOUR DEFINITION GOES HERE/ } Powerll: Power(string newname, int newdmg); string get_name() const; int get_damagel) const; int Fighter::get_speed() const! /*YOUR DEFINITION GOES HERE*/ } bool Fighterswap_power const Power& oldpower, const Power& newpower){ /*YOUR DEFINITION GOES HERE/ } private: int Fighter::get_health() const { /*YOUR DEFINITION GOES HERE/ } int main string name = "";// int damage = -1;// A string name for the Power object. Default value should be An integer damage for the Power object. Default value should be-1 string Fighter::get_name() const /*YOUR DEFINITION GOES HERE*/ } }; Power::Power(){/*intentionally empty*/} Power::Power(string newname, int newdmg) name(newname), damage(newdmg) {} const string P1_NAME = "Fireball"; const string P2_NAME = 'Thunder"; const string P3_NAME = "Meteo"; const int P1_DMG = 5; const int P2_DMG = 10; const int P3_DMG = 9999; int Fighter::get_attack() const /*YOUR DEFINITION GOES HERE*/ } string Power:get_name() const { /*YOUR DEFINITION GOES HERE/ } void Fighter::take_damage(int newdamage/ /*YOUR DEFINITION GOES HERE*/ } int Power::get_damagel) const /*YOUR DEFINITION GOES HERE*/ } const int F1_SPEED = 5; const int F2_SPEED = 9; const int F1_HEALTH = 100; const int F2_HEALTH = 99; const int F1_ATK = 9; const int F2_ATK = 5; const string F1_NAME = "Ryu"; const string F2_NAME = "Ken"; bool Fighter::is_conscious() const /*YOUR DEFINITION GOES HERE*/ } class Fighter private void Fighter::set_speed[int spd) /*YOUR DEFINITION GOES HERE*/ Powerf_ball P1_NAME, P1_DMG); Power thund( P2_NAME, P2_DMG); Power meteo P3_NAME, P3_DMG); vector ryu_powers = {f_ball); vectors Power> power_vector; string name = ""; int speed = -1; int health = -1; int attack = -1; //A string name for the Fighter object. Default value is ". // An integer speed for the Fighter object. Default value is -1. //An integter health for the Fighter object. Default value is -1. void Fighter set_health(int hpX /*YOUR DEFINITION GOES HERE*/ } Fighter ryu[ F1_NAME, F1_ATK, F1_SPEED, F1_HEALTH, ryu_powers); public: void Fighter::set_attacklint atk){ /*YOUR DEFINITION GOES HERE*/ } cout & newpowers); int get_speed() const; //Purpose: Get the speed of the Fighter int get_health() const; //Purpose: Get the health of the Fighter int get_attack() const; //Purpose: Get the attack of the Fighter string get_name() const; // Purpose: Get the name of the Fighter void set_speed[int spd); //Purpose: Set the speed of the Fighter void set_health(int hp); //Purpose: Set the health of the Fighter void set_attackfint atk); //Purpose: Set the attack of the Fighter void set_name(string nm); //Purpose: Set the name of the Fighter void take_damage(int newdamage); //Purpose: Subtract damage from health. End of docum void Fighter:print_powers() const! for(int i = 0; i #include #include } using namespace std; Fighter::Fighter(/*intentionally empty*/} Fighter::Fighter(string newname, int newattack, int newspeed, int newhealth const vector&newpowers) name(newname), attack newattack), speed(newspeed), healthewhealth), power_vector(newpowers) //*intentionally empty*/ bool Fighterswap_power(int index, const Power& newpower){ /*YOUR DEFINITION GOES HERE/ class Power public: bool Fighter swap_power(const string& opname, const Power& newpower){ /+YOUR DEFINITION GOES HERE/ } Powerll: Power(string newname, int newdmg); string get_name() const; int get_damagel) const; int Fighter::get_speed() const! /*YOUR DEFINITION GOES HERE*/ } bool Fighterswap_power const Power& oldpower, const Power& newpower){ /*YOUR DEFINITION GOES HERE/ } private: int Fighter::get_health() const { /*YOUR DEFINITION GOES HERE/ } int main string name = "";// int damage = -1;// A string name for the Power object. Default value should be An integer damage for the Power object. Default value should be-1 string Fighter::get_name() const /*YOUR DEFINITION GOES HERE*/ } }; Power::Power(){/*intentionally empty*/} Power::Power(string newname, int newdmg) name(newname), damage(newdmg) {} const string P1_NAME = "Fireball"; const string P2_NAME = 'Thunder"; const string P3_NAME = "Meteo"; const int P1_DMG = 5; const int P2_DMG = 10; const int P3_DMG = 9999; int Fighter::get_attack() const /*YOUR DEFINITION GOES HERE*/ } string Power:get_name() const { /*YOUR DEFINITION GOES HERE/ } void Fighter::take_damage(int newdamage/ /*YOUR DEFINITION GOES HERE*/ } int Power::get_damagel) const /*YOUR DEFINITION GOES HERE*/ } const int F1_SPEED = 5; const int F2_SPEED = 9; const int F1_HEALTH = 100; const int F2_HEALTH = 99; const int F1_ATK = 9; const int F2_ATK = 5; const string F1_NAME = "Ryu"; const string F2_NAME = "Ken"; bool Fighter::is_conscious() const /*YOUR DEFINITION GOES HERE*/ } class Fighter private void Fighter::set_speed[int spd) /*YOUR DEFINITION GOES HERE*/ Powerf_ball P1_NAME, P1_DMG); Power thund( P2_NAME, P2_DMG); Power meteo P3_NAME, P3_DMG); vector ryu_powers = {f_ball); vectors Power> power_vector; string name = ""; int speed = -1; int health = -1; int attack = -1; //A string name for the Fighter object. Default value is ". // An integer speed for the Fighter object. Default value is -1. //An integter health for the Fighter object. Default value is -1. void Fighter set_health(int hpX /*YOUR DEFINITION GOES HERE*/ } Fighter ryu[ F1_NAME, F1_ATK, F1_SPEED, F1_HEALTH, ryu_powers); public: void Fighter::set_attacklint atk){ /*YOUR DEFINITION GOES HERE*/ } cout & newpowers); int get_speed() const; //Purpose: Get the speed of the Fighter int get_health() const; //Purpose: Get the health of the Fighter int get_attack() const; //Purpose: Get the attack of the Fighter string get_name() const; // Purpose: Get the name of the Fighter void set_speed[int spd); //Purpose: Set the speed of the Fighter void set_health(int hp); //Purpose: Set the health of the Fighter void set_attackfint atk); //Purpose: Set the attack of the Fighter void set_name(string nm); //Purpose: Set the name of the Fighter void take_damage(int newdamage); //Purpose: Subtract damage from health. End of docum void Fighter:print_powers() const! for(int i = 0; i

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

Oracle Database Upgrade Migration And Transformation Tips And Techniques

Authors: Edward Whalen ,Jim Czuprynski

1st Edition

0071846050, 978-0071846059

More Books

Students also viewed these Databases questions