Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C++ program which has a main-driver and classes to make a role-playing g

ID: 3910429 • Letter: W

Question

Write a C++ program which has a main-driver and classes to make a role-playing game
(i.e. repeated encounters with enemies who have hitpoints, health, and treasure value
attributes).   

A base class called Characters is used to

define:
derived class Good_Guy who is the play AKA good-guy
and
also derived class Bad_Guy.

The base class Character has    
fields named:  
            health,
            hit_points (damage to enemy health),
            treasure_value

The Good_Guy also has an added attribute:
            treasure = total treasure collected so far, starting at 0 at constructor-time.
The Good_Guy has:
            health = 100,
            hit_points (damage to enemy health) = 0 thru 100 (equally likely but random),
            treasure_value (not relveant)

Bad Guys are of 3 types
            Wizard                 with health 30,
                                          hit_points=25      
                                          treasure value (to good guy) if Wizard killed =20
             Dragon                with health 50,
                                          hit_points=20      
                                          treasure value (to good guy) if Dragon   killed=40
             Mouse               with health,
                                          hit_points=10      
                                          treasure value (to good guy) if Mouse killed=5

Your main driver will consist primarily of a
single for-loop    // Loop until you make $100 or die (0 health left)
{     cout << " You encounter a";
       Randomly generate bad guy 50% of the time OR go default case 50% of the time
       switch (C)
           {    case "W" :   _______________________
                                     Good_Guy.mutator for health goes down by hit-point of Wizard
                                     break ;
                 case "D":    _______________________
                                      Good_Guy.mutator for health goes down by hit-point of Dragon
                                     break ;
                 case "M":    _______________________
                                      Good_Guy.mutator for health goes down by hit-point of Mouse
                                     break ;
                 // These are not WMD's
                 default :        cout << " no one. You are safe!"
            }     
}  

The WDM cases will need mutators and selectors to do damage to good guy, bad guy,
and treasure adding for good guy.

Loop until you make $100 or good_guy dies (0 health left)


Make sure to request points at constructor time in the driver.
The driver should show a menu like: P for Polygon, T for Triangle, and Q for Quadrilateral.
After recieving the data, the driver should print the perimeter and area.

Explanation / Answer

#include <iostream>

using namespace std;

// Base class

class Characters {

                private:

                                int health;

                                int hit_points;

                                int treasure_value;

                public:

                                Characters(int h, int hp, int tv) {

                                                health = h;

                                                hit_points = hp;

                                                treasure_value = tv;

                                }

                                int getHealth() {

                                                return health;

                                }

                                int getHit_points() {

                                                return hit_points;

                                }

                                int getTreasure_value() {

                                                return treasure_value;

                                }

                                void setHealth(int h) {

                                                health = h;

                                }

                                void setHit_points(int hp) {

                                                hit_points = hp;

                                }

};

// Derived class

class Bad_Guy: public Characters {

                public:

                                Bad_Guy(int h, int hp, int tv): Characters(h, hp, tv) {

                                }

};

// Derived class

class Good_Guy: public Characters {

                private:

                                int treasure;

                public:

                                Good_Guy(): Characters(100, 0, 0) {

                                                treasure = 0;

                                }

                                int getTotalTeasure() {

                                                return treasure;

                                }

                                void healthDown(Bad_Guy b) {

                                                setHealth(getHealth() - b.getHealth());

                                                setHit_points(getHit_points() + b.getHit_points());

                                                treasure = treasure + b.getTreasure_value();

                                }

};

int main(void) {

                Good_Guy goodboy;

                Bad_Guy bw(30, 25, 20);

                Bad_Guy bd(50, 20, 40);

                Bad_Guy bm(0, 10, 5);

                for( ; goodboy.getTotalTeasure() < 100 && goodboy.getHealth() > 0; ) {

                                cout << endl << "Total Teasure : " << goodboy.getTotalTeasure();

                                cout << endl << "Health : " << goodboy.getHealth();

                                char C;

                                cout << endl << "Enter C : ";

                                cin >> C;

                                switch (C)

                                {   

                                                case 'W' :

                                                                goodboy.healthDown(bw);

                                                                break ;

                                                case 'D':

                                                                goodboy.healthDown(bd);

                                                                break ;

                                                case 'M':

                                                                goodboy.healthDown(bm);

                                                                break ;

                                                // These are not WMD's

                                                default :       

                                                                cout << endl << " no one. You are safe!";

                                }    

                }

                return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote