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

Thank you :) class FighterHerof public int health public FighterHero(){ health r

ID: 3572765 • Letter: T

Question

Thank you :)
class FighterHerof public int health public FighterHero(){ health rand() 20-180: public int attack int attackpoints rand() 10+10: return attackpointsi public void damage int points) health health-points: class FighterMonster public int health: public FighterMonsterC){ health rand 20-180 public int attack int attack points rand 10+10: return attack points; public void int points) health health-pointsi string attackname int n){ switch case 01 return "Fuamethrowar case 11 retum "Waterblast case 21 return Bone claws case 31 return "Electric shock" case 4: return "Magicalstorm" return "Invalid attack"

Explanation / Answer

//Creating FighterHero class
class FighterHero
{
   public :
       //Here we are Declaring a variable named health of type integer
       int health;
       public :
       /* Zero argumented constructor.
       * This constructor will be called and executed
       * when ever we are creating an object
       * to the FighterHero class
       * When ever this constructor is called a
       * random number will be generated between
       * 180 and 199 inclusive.
       * That random number will be assigned
       * to health variable of FighterHero class
       */
   FighterHero()
       {
           srand((unsigned)time(0));
           //Generating a random number between 180 and 199 inclusive
               health=rand()%20+180;  
       };
       public:
           /* When this method is executed a random number
           * will be generated between 10 and 19 inclusive
           * and assigned that number to a variable named
           * attackpoints and returning it
           */
           int attack(){
              //Generating a random number between 10 and 19
              int attackpoints=rand()%10+10;
              return attackpoints;
           }
           public :
              /* When this method is called by passing
               * the integer type value as argument then that value
               * is deducted from the health of the FighterHero.
               */
              void damage(int points)
              {
                  //Deducting the no of points from the health variable
                  health=health-points;
               }
             
};

//Creating FighterMonster class
class FighterMonster{
   public :
       //Here we are Declaring a variable named health of type integer
       int health;
       public :
       /* Zero argumented constructor.
       * This constructor will be called and executed
       * when ever we are creating an object
       * to the FighterMonster class
       * When ever this constructor is called a
       * random number will be generated between
       * 180 and 199 inclusive.
       * That random number will be assigned
       * to health variable of FighterMonster class
       */
           FighterMonster(){
               //Generating a random number between 180 and 199 inclusive
               health=rand()%20+180;  
           };
               public:
           /* When this method is executed a random number
           * will be generated between 10 and 19 inclusive
           * and assigned that number to a variable named
           * attackpoints and returning it
           */
           int attack(){
              //Generating a random number between 10 and 19
              int attackpoints=rand()%10+10;
              return attackpoints;
           }
           public :
              /* When this method is called by passing
               * the integer type value as argument then that value
               * is deducted from the health of the FighterHero.
               */
              void damage(int points)
              {
              //Deducting the no of points from the health variable
                  health=health-points;
               }
          
};

/* When this method is executed by passing
* the an integer between 1 and 4(inclusive)
* based on the integer corresponding case
* will get executed and return a string.
* If any other number is passed as input
* "Invalid attack" string will be returned.
*/
string attackname(int n)
{
   switch(n)
   {
       case 0:
           return "Flamethrow";
                   case 1:
           return "waterblast";
           case 2:
           return "boneclows";
           case 3:
           return "ElectricShock";
           case 4:
           return "magical storm";
   }
   return "invalid attack";
}

__________Thank You

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