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

hello there, i need help in C++. i am taking this course, which i regret now bec

ID: 3667266 • Letter: H

Question

hello there,

i need help in C++. i am taking this course, which i regret now because it is hard to understand, in computer science. i have an assignment due tomorrow. i need your help by giving me a similar program or doing two charactors of this game so that i knw how to do the code if that is possible:

You will create a simple class hierarchy as the basis for a fantasy combat game. Your 'universe' contains the following creatures. Each will have characteristics for attack, defense, armor, and strength points Attack 1d6 *Rin 2d6 1d6 *Soul 2d10 1d20+2d6* Armor Strength Points Gollum Barbarian Baba Yaga Blue Men Unicorrn Defense 2d6 2d6 1d10 3d6* 2d6 *Unicorn 0 3 12 *Mob 18 3d6 is rolling three 6-sided dice. 2d10 is rolling two 10-sided dice *Soul- Baba Yaga feeds on the pain and suffering of others. When she makes a successful attack her attack roll is applied to her opponent, but she gains points equal to the points lost by her opponent. For example, she makes an attack and 3 points of damage are inflicted. She increases her strength points by 3 also. Her total can exceed 12. She wears no physical armor but has many spells and enchantments to protect her. *Unicorn- Unicorns are peaceful creatures. They will only defend until they received damage. The following turn they will attack with their horn (1d20) and their hooves (2d6). Unless they face another Unicorn. They are very territorial and will immediately fight another unicorn to the death. *Ring- Gollum has the one ring. It can make him invisible. That makes him harder to hit. It also allows him to occasionally surprise his opponent. There is a 5% chance he makes an attack with 3d6 *Mob- The Blue Men are actually a swarm of small pictsies. For every 4 points of damage (round down) they lose 1 defense die. Such as, when they reach strength of 8 they only have 2d6 for defense To resolve an attack you will need to generate 2 dice rolls. The attacker rolls the appropriate number and type of dice under Attack. The defender rolls the appropriate number and type of dice under Defense. You subtract the Defense roll from the Attack roll. That is the damage. Each class only has its own information or data. When O1 is fighting 02 your program should call O1's attack function. It will return the damage inflicted. Then O2's defense function will take the damage inflicted, then roll the specified dice and subtract the points for the defense. To apply the damage you subtract the Armor value. The result is then subtracted from the Strength Points. That value becomes the new Strength Points for the next round. If Strength Points goes to 0 or less then the character is out of the combat. If it receives 8 points of damage and rolls 3 for it's defense and has an armor of 3 it would take 8 subtract 3 and then 3 for the armor to receive 2 points of damage. You need to create a Creature class. Then you will have a subclass for each of these characters. Note that the Creature class will be an abstract class with both the virtual attack and virtual defense functions. You will never instantiate one. Since each starts with the same data elements you will only need one constructor. It is part of your design task to determine what functions you will need. The only values that can change are the Strength Points and the number of dice for the Gollum and Hydra special abilities

Explanation / Answer


#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <queue>
#include <stack>
#include "creature.h"
using std::cout;
using std::cin;
using std::endl;
using std::string;
using std::vector;
using std::queue;
using std::stack;

/* inputInt() with two arguments verifies that a user input integer is between
   the two input integers, inclusive. */
int inputInt(int lower, int upper);
/* inputInt() with one argument verifies that a user input integer is greater
   than the argument input integer. */
int inputInt(int lower);
/* inputString() verifies that a user input string is nonempty. */
string inputString();
/* populateLineup() populates a team's lineup with a number of fighters and
   gives each fighter a team name. */
void populateLineup(queue<Creature*>& lineup, int fighters, string team);
/* combat() resolves combat between two Creatures. */
void combat(Creature* unit1, Creature* unit2);
/* tournament() manages the lineups for both teams and the loser stacks for
   both teams. Uses combat() for each pair of fighters. */
void tournament(queue<Creature*>& lineup1, stack<Creature*>& loser1,
   queue<Creature*>& lineup2, stack<Creature*>& loser2);
/* tournamentResults() determines the winners of the tournament. */
void tournamentResults(queue<Creature*>& lineup1, stack<Creature*>& loser1,
   queue<Creature*>& lineup2, stack<Creature*>& loser2);

int main()
{
   srand(time(NULL));
   queue<Creature*> lineup1;
   queue<Creature*> lineup2;
   stack<Creature*> loser1;
   stack<Creature*> loser2;
   cout << "Welcome to the Creature Tournament!" << endl
       << "Two players field one team each, with some number of fighters."
       << endl;

   cout << "How many fighters to a team (at least 2)?" << endl;
   int fighters;
   fighters = inputInt(1);

   cout << "Fill the lineup for player 1!" << endl;
   cout << "Give a team name (e.g. Team Awesome):" << endl;
   string teamName1;
   teamName1 = inputString();
   populateLineup(lineup1, fighters, teamName1);
   cout << endl;

   cout << "Fill the lineup for player 2!" << endl;
   cout << "Give a team name (e.g. Team Amazing):" << endl;
   string teamName2;
   teamName2 = inputString();
   while (teamName2 == teamName1)
   {
       cout << "Please enter a different team name!" << endl;
       teamName2 = inputString();
   }
   populateLineup(lineup2, fighters, teamName2);
   cout << endl;

   tournament(lineup1, loser1, lineup2, loser2);

   tournamentResults(lineup1, loser1, lineup2, loser2);

   cout << "Thanks for playing!" << endl;

   return 0;
}

/* populateLineup() takes a queue of Creature pointers, a number of fighters
   to populate the queue with, and a team name to create a lineup of Creatures
   for the tournament. */
void populateLineup(queue<Creature*>& lineup, int fighters, string team)
{
   for (int i = 0; i < fighters; i++)
   {
       cout << "1. Goblin" << endl
           << "2. Barbarian" << endl
           << "3. Reptile person" << endl
           << "4. Blue man" << endl
           << "5. The Shadow" << endl;
       cout << "Choose a fighter to add (1-5): ";
       int choice;
       choice = inputInt(1, 5);

       string name;
       cout << "Give your fighter a name: ";
       name = inputString();

       switch (choice)
       {
           case 1:
           {
               Creature* temp = new Goblin(name, team);
               lineup.push(temp);
               break;
           }
           case 2:
           {
               Creature* temp = new Barbarian(name, team);
               lineup.push(temp);
               break;
           }
           case 3:
           {
               Creature* temp = new Reptile(name, team);
               lineup.push(temp);
               break;
           }
           case 4:
           {
               Creature* temp = new BlueMen(name, team);
               lineup.push(temp);
               break;
           }
           case 5:
           {
               Creature* temp = new Shadow(name, team);
               lineup.push(temp);
               break;
           }
       }
   }
}

/* combat() function. A "coin toss" determines who attacks first, then vice
   versa, until one unit's strength value is equal to or less than 0. */
void combat(Creature* unit1, Creature* unit2)
{
   cout << unit1->showTeam() << "'s " << unit1->showName() << " the "
       << unit1->showType() << " versus " << unit2->showTeam() << "'s "
       << unit2->showName() << " the " << unit2->showType() << "!"
       << endl;
   int coinToss;
   coinToss = rand() % 2;
   if (coinToss == 0)
   {
       cout << unit1->showTeam() << "'s " << unit1->showName() << " the "
           << unit1->showType() << " goes first!" << endl << endl;
       while (unit1->isAlive() && unit2->isAlive())
       {
           // unit1 attacks first
           unit1->combatTurn(unit1, unit2);
           // unit2 attacks unit1 if unit2 still has strength > 0
           if (unit2->isAlive())
           {
               unit1->combatTurn(unit2, unit1);
           }
       }
   }
   else
   {
       cout << unit2->showTeam() << "'s " << unit2->showName() << " the "
           << unit2->showType() << " goes first!" << endl << endl;
       while (unit1->isAlive() && unit2->isAlive())
       {
           // unit2 attacks first
           unit2->combatTurn(unit2, unit1);
           // unit2 attacks unit1 if unit2 still has strength > 0
           if (unit1->isAlive())
           {
               unit2->combatTurn(unit1, unit2);
           }
       }
   }

   if (unit1->isAlive())
   {
       cout << unit2->showTeam() << "'s " << unit2->showName() << " the "
           << unit2->showType() << " has fallen! "
           << unit1->showTeam() << "'s " << unit1->showName() << " the "
           << unit1->showType() << " wins!" << endl;
   }
   else
   {
       cout << unit1->showTeam() << "'s " << unit1->showName() << " the "
           << unit1->showType() << " has fallen! "
           << unit2->showTeam() << "'s " << unit2->showName() << " the "
           << unit2->showType() << " wins!" << endl;
   }

   if (unit1->isAlive())
   {
       unit1->regainStrength();
       unit1->addPoints(unit2);
       cout << unit1->showTeam() << "'s " << unit1->showName() << " the "
           << unit1->showType() << " has " << unit1->showPoints()
           << " points." << endl;
   }
   else
   {
       unit2->regainStrength();
       unit2->addPoints(unit1);
       cout << unit2->showTeam() << "'s " << unit2->showName() << " the "
           << unit2->showType() << " has " << unit2->showPoints()
           << " points." << endl;
   }
}

/* tournament() encompasses the fighting between the two lineups for the tournament. */
void tournament(queue<Creature*>& lineup1, stack<Creature*>& loser1,
   queue<Creature*>& lineup2, stack<Creature*>& loser2)
{
   cout << "Let the tournament begin!" << endl << endl;
   while (lineup1.size() > 0 && lineup2.size() > 0)
   {
       Creature* unit1 = lineup1.front();
       Creature* unit2 = lineup2.front();
       lineup1.pop();
       lineup2.pop();
       combat(unit1, unit2);
       cout << "This round is over!" << endl << endl << endl;

       if (unit1->isAlive())
       {
           lineup1.push(unit1);
           loser2.push(unit2);
       }
       else
       {
           loser1.push(unit1);
           lineup2.push(unit2);
       }
   }
   // // debugging
   // cout << lineup1.size() << " " << lineup2.size() << endl;
   // cout << loser1.size() << " " << loser2.size() << endl;
}

/* tournamentResults() outputs the results of the tournament. It first gets
   the name of the team that still has living fighters. */
void tournamentResults(queue<Creature*>& lineup1, stack<Creature*>& loser1,
   queue<Creature*>& lineup2, stack<Creature*>& loser2)
{
   vector<Creature*> standings;
   // store team with members still in queue
   // last team standing
   string lastTeam;
   if (!lineup1.empty())
   {
       lastTeam = lineup1.front()->showTeam();
   }
   else
   {
       lastTeam = lineup2.front()->showTeam();
   }

   // get team names before putting fighters into the vector
   string team1;
   if (!lineup1.empty())
   {
       team1 = lineup1.front()->showTeam();
   }
   else
   {
       team1 = loser1.top()->showTeam();
   }

   string team2;
   if (!lineup2.empty())
   {
       team2 = lineup2.front()->showTeam();
   }
   else
   {
       team2 = loser2.top()->showTeam();
   }

   // get team points while putting fighters into vector
   int teamPts1 = 0;
   // copy all Creatures to a vector
   while (!lineup1.empty())
   {
       teamPts1 += lineup1.front()->showPoints();
       standings.push_back(lineup1.front());
       lineup1.pop();
   }
   while (!loser1.empty())
   {
       teamPts1 += loser1.top()->showPoints();
       standings.push_back(loser1.top());
       loser1.pop();
   }

   int teamPts2 = 0;
   while (!lineup2.empty())
   {
       teamPts2 += lineup2.front()->showPoints();
       standings.push_back(lineup2.front());
       lineup2.pop();
   }
   while (!loser2.empty())
   {
       teamPts2 += loser2.top()->showPoints();
       standings.push_back(loser2.top());
       loser2.pop();
   }

   // sort in descending order by points the fighters
   // bubble sort
   Creature* temp;
   bool swap;
   do
   {
       swap = false;
       for (unsigned int i = 0; i < (standings.size() - 1); i++)
       {
           if (standings.at(i)->showPoints() <
               standings.at(i + 1)->showPoints())
           {
               temp = standings.at(i);
               standings.at(i) = standings.at(i + 1);
               standings.at(i + 1) = temp;
               swap = true;
           }
       }
   }
   while (swap);
cout << "Team results: " << endl;
   cout << "The team with the last member(s) standing: " << lastTeam
       << "!" << endl;

   if (teamPts1 > teamPts2)
   {
       cout << team1 << " wins with a total of " << teamPts1 << " points!"
           << endl;
       cout << team2 << " had " << teamPts2 << " points." << endl << endl;
   }
   else if (teamPts2 > teamPts1)
   {
       cout << team2 << " wins with a total of " << teamPts2 << " points!"
           << endl;
       cout << team1 << " had " << teamPts1 << " points." << endl << endl;
   }
   else
   {
       cout << team1 << " and " << team2 << " tied with " << teamPts1
           << " points each!" << endl << endl;
   }

   cout << "Individual results: " << endl;
   if (standings.size() < 3)
   {
       cout << "Something's wrong. You should have at least 4 total fighers."
           << endl;
       exit(1);
   }
   else
   {
       // ignoring ties
       cout << "First place: "
               << standings.at(0)->showTeam() << "'s "
               << standings.at(0)->showName() << " the "
               << standings.at(0)->showType() << ", with "
               << standings.at(0)->showPoints() << " points!" << endl;
       cout << "Second place: "
               << standings.at(1)->showTeam() << "'s "
               << standings.at(1)->showName() << " the "
               << standings.at(1)->showType() << ", with "
               << standings.at(1)->showPoints() << " points!" << endl;
       cout << "Third place: "
               << standings.at(2)->showTeam() << "'s "
               << standings.at(2)->showName() << " the "
               << standings.at(2)->showType() << ", with "
               << standings.at(2)->showPoints() << " points!" << endl;
   }

   cout << endl << endl;

   // deleting objects from memory, not just the pointers to the objects
   for (unsigned int i = 0; i < standings.size(); i++)
   {
       Creature* temp2 = standings.at(i);
       delete temp2;
       // if the destructor in creature.cpp and creature.h is commented out
       // you can see the confirmation messages
   }

   standings.clear();
   // removes all elements from the vector and destroys
}

/* inputInt() verifies integer input and ensures that it falls within a range. */
int inputInt(int lower, int upper)
{
   int tempNum;
   cin >> tempNum;
   while (cin.fail() || (tempNum < lower || tempNum > upper))
   {
       cin.clear();
       cin.ignore();
       cout << "Please enter an integer from " << lower << " to "
           << upper << ": ";
       cin >> tempNum;
   }
   cin.ignore(1000, ' ');
   return tempNum;
}

/* inputInt() verifies user integer input */
int inputInt(int lower)
{
   int tempNum;
   cin >> tempNum;
   while (cin.fail() || (tempNum <= lower))
   {
       cin.clear();
       cin.ignore();
       cout << "Please enter an integer greater than " << lower << ": ";
       cin >> tempNum;
   }
   cin.ignore(1000, ' ');
   return tempNum;
}

/* inputString() verifies that a string input is nonempty. */
string inputString()
{
   string tempString("");
   getline(cin, tempString);
   while (tempString.length() == 0 || cin.fail())
   {
       cout << "Name is empty; try again: ";
       getline(cin, tempString);
   }
   return tempString;
}

creature.cpp
#include <iostream>
#include <string>
#include <ctime>
#include <cstdlib>
#include "creature.h"
using std::cout;
using std::endl;
using std::string;

/********************** Creature **********************/

/* Default constructor for the Creature abstract base class. Intentionally
   left blank. */
Creature::Creature()
{
   // intentionally left blank
}

/* attack() function for the Creature class. */
int Creature::attack(Creature* target)
{
   int attackSum = 0;
   for (int i = 0; i < attackDice; i++)
   {
       attackSum += rand() % attackSides + 1;
   }
   return attackSum;
}

/* defense() function for the Creature class. */
int Creature::defense()
{
   int defenseSum = 0;
   for (int i = 0; i < defenseDice; i++)
   {
       defenseSum += rand() % defenseSides + 1;
   }
   return defenseSum;
}

/* combatTurn() function for the Creature class.*/
void Creature::combatTurn(Creature* attacker, Creature* defender)
{
   // show defense strength at beginning of round
   cout << defender->showTeam() << "'s " << defender->showName() << " the "
       << defender->showType() << " has " << defender->showStrength()
       << " strength." << endl;
   // displays who attacks whom
   cout << attacker->showTeam() << "'s " << attacker->showName() << " the "
       << attacker->showType() << " attacks "
       << defender->showTeam() << "'s " << defender->showName() << " the "
       << defender->showType() << "!" << endl;

   // rolls attack and defense
   int attackRoll = attacker->attack(defender);
   int defenseRoll = defender->defense();

   cout << attacker->showTeam() << "'s " << attacker->showName() << " the "
       << attacker->showType() << " rolls an attack of "
       << attackRoll << ", and" << endl << defender->showTeam() << "'s "
       << defender->showName() << " the "
       << defender->showType();

   // if the Shadow dodges
   if (defenseRoll == 0 && defender->showType() == "Shadow")
   {
       cout << " successfully dodges the attack!" << endl;
   }
   // Achilles strike nullifies the defense!
   // only for Goblin attackers and non-Goblin defenders
   else if (attackRoll == 12 && attacker->showType() == "Goblin"
       && defender->showType() != "Goblin")
   {
       cout << "'s defense is useless against the Achilles strike!"
           << endl;
   }
   else
   {
       cout << " rolls a defense of " << defenseRoll << " and has "
           << defender->armor << " armor." << endl;
   }
  
   // need to make sure attack > defense + armor
   // or else attack deals no damage
   if (defenseRoll == 0 && defender->showType() == "Shadow")
   {
       cout << "No damage is dealt to " << defender->showTeam()
           << "'s " << defender->showName() << " the Shadow!" << endl;
   }
   // Achilles strike nullifies defense roll!
   // Goblin attacker rolls 12 and non-Goblin defender
   else if (attackRoll == 12 && attacker->showType() == "Goblin"
       && defender->showType() != "Goblin")
   {
       // first case doesn't happen, as all armor is less than 12
       if (defender->armor >= attackRoll)
       {
           cout << "The " << defender->showTeam() << "'s "
               << defender->showName() << " the "
               << defender->showType()
               << "'s defense is breached by the Achilles "
               << "attack, but the armor nullifies the "
               << "attack!" << endl;
       }
       // calculuate damage based on just attack and armor
       else
       {
           cout << attacker->showTeam() << "'s " << attacker->showName()
               << " the " << attacker->showType() << " deals "
               << attackRoll - defender->armor << " damage to "
               << defender->showTeam() << "'s " << defender->showName()
               << " the " << defender->showType() << "."
               << endl;
           defender->strength -= (attackRoll - defender->armor);
       }
   }
   // normal attack where armor + defense >= attack
   else if ((defenseRoll + defender->armor) >= attackRoll)
   {
       cout << defender->showTeam() << "'s " << defender->showName()
           << " the " << defender->showType()
           << "'s defense and armor " << "nullify the attack!"
           << endl;
   }
   // normal attack where attack > armor + defense
   else
   {
       cout << attacker->showTeam() << "'s " << attacker->showName()
           << " the " << attacker->showType() << " deals "
           << attackRoll - defenseRoll - defender->armor
           << " damage to " << defender->showTeam() << "'s "
           << defender->showName() << " the " << defender->showType() << "."
           << endl;
       defender->strength -= (attackRoll - defenseRoll
           - defender->armor);
   }
  
   // prevents negative strength
   if (defender->showStrength() < 0)
   {
       defender->strength = 0;
   }

   cout << defender->showTeam() << "'s " << defender->showName()
       << " the " << defender->showType() << "'s strength is now "
       << defender->showStrength() << "." << endl;
   cout << endl;
}

/* regainStrength() function for the Creature class. */
void Creature::regainStrength()
{
   int missingHP;
   missingHP = this->maxStrength - this->strength;
   cout << this->team << "'s " << this->name << " the " << this->type
       << " is missing " << missingHP << " strength!" << endl;
   // if no health is missing, function ends
   if (missingHP == 0)
   {
       cout << this->team << "'s " << this->name << " the " << this->type
           << " is at full strength, at " << this->strength << "." << endl;
       return;
   }
   // 1 in 4 chance to regain all health; otherwise, regain half of missing
   // health
   int healthChance;
   healthChance = rand() % 4;
   if (healthChance == 0)
   {
       cout << this->team << "'s " << this->name << " the " << this->type
           << " luckily regains all of its missing strength!"
           << endl;
       strength += missingHP;
       cout << this->team << "'s " << this->name << " the " << this->type
           << " now has " << this->strength << " strength." << endl;
   }
   else
   {
       cout << this->team << "'s " << this->name << " the " << this->type
           << " regains half of its missing strength." << endl;
       strength += missingHP / 2;
       cout << this->team << "'s " << this->name << " the " << this->type
           << " now has " << this->strength << " strength." << endl;
   }
}

/* Accessor function for attackDice. */
int Creature::showAttackDice()
{
   return this->attackDice;
}

/* Accessor function for attackSides. */
int Creature::showAttackSides()
{
   return this->attackSides;
}

/* Accessor function for defenseDice. */
int Creature::showDefenseDice()
{
   return this->defenseDice;
}

/* Accessor function for defenseSides. */
int Creature::showDefenseSides()
{
   return this->defenseSides;
}

/* Accessor function for armor. */
int Creature::showArmor()
{
   return this->armor;
}

/* Accessor function for strength. */
int Creature::showMaxStrength()
{
   return this->maxStrength;
}

/* Accessor function for current strength. */
int Creature::showStrength()
{
   return this->strength;
}

/* Accessor function for current points. */
int Creature::showPoints()
{
   return this->points;
}

/* Accessor function for type. */
string Creature::showType()
{
   return this->type;
}

/* Accessor function for name. */
string Creature::showName()
{
   return this->name;
}

/* Accessor function for team. */
string Creature::showTeam()
{
   return this->team;
}

/* Accessor function for isGoblin. */
bool Creature::showIsGoblin()
{
   return isGoblin;
}

/* isAlive() function for the Creature class. Returns a boolean based on if the
   object's strength is greater than 0 or not. */
bool Creature::isAlive()
{
   if (strength > 0)
   {
       return true;
   }
   else
   {
       return false;
   }
}

/* Mutator function for attackSides. */
void Creature::setAttackSides(int value)
{
   attackSides = value;
}

/* Mutator function for type. Only used when two of the same creature are
   fighting each other. */
void Creature::setName(string inputName)
{
   this->name = inputName;
}

/********************** Goblin **********************/

/* Default constructor for the Goblin derived class. */
Goblin::Goblin() : Creature()
{
   attackDice = 2;
   attackSides = 6;
   defenseDice = 1;
   defenseSides = 6;
   armor = 3;
   maxStrength = 8;
   strength = 8;
   points = 0;
   isGoblin = true;
   type = "Goblin";
   name = "";
}

/* Constructor for the Goblin derived class that takes a name as a string and
   a team name as a string. */
Goblin::Goblin(string inputName, string teamName) : Creature ()
{
   attackDice = 2;
   attackSides = 6;
   defenseDice = 1;
   defenseSides = 6;
   armor = 3;
   maxStrength = 8;
   strength = 8;
   points = 0;
   isGoblin = true;
   type = "Goblin";
   name = inputName;
   team = teamName;
}

/* attack() function for the Goblin derived class. */
int Goblin::attack(Creature* target)
{
   int attackSum = 0;
   for (int i = 0; i < attackDice; i++)
   {
       attackSum += rand() % attackSides + 1;
   }
   if (attackSum == 12 && target->showIsGoblin() == false)
   {
       target->setAttackSides(target->showAttackSides() / 2);
       cout << "The goblin hit the Achilles of the "
           << target->showType() << "!" << endl;
       cout << "The attack power of the " << target->showType()
           << " is now " << target->showAttackDice() << "d"
           << target->showAttackSides() << "!" << endl;
   }
   return attackSum;
}

/* addPoints() function for the Goblin derived class. */
void Goblin::addPoints(Creature* target)
{
   if (target->showType() == "Goblin")
   {
       points += 3;
   }
   else if (target->showType() == "Barbarian")
   {
       points += 4;
   }
   else if (target->showType() == "Reptile Person")
   {
       points += 7;
   }
   else if (target->showType() == "Blue Man")
   {
       points += 10;
   }
   else if (target->showType() == "Shadow")
   {
       points += 8;
   }
}

/********************** Barbarian **********************/

/* Default constructor for the Barbarian derived class. */
Barbarian::Barbarian() : Creature()
{
   attackDice = 2;
   attackSides = 6;
   defenseDice = 2;
   defenseSides = 6;
   armor = 0;
   maxStrength = 12;
   strength = 12;
   points = 0;
   isGoblin = false;
   type = "Barbarian";
}

/* Constructor for the Barbarian derived class that takes a name as a string
   and a team name as a string. */
Barbarian::Barbarian(string inputName, string teamName) : Creature()
{
   attackDice = 2;
   attackSides = 6;
   defenseDice = 2;
   defenseSides = 6;
   armor = 0;
   maxStrength = 12;
   strength = 12;
   points = 0;
   isGoblin = false;
   type = "Barbarian";
   name = inputName;
   team = teamName;
}

/* addPoints() function for the Barbarian derived class. */
void Barbarian::addPoints(Creature* target)
{
   if (target->showType() == "Goblin")
   {
       points += 2;
   }
   else if (target->showType() == "Barbarian")
   {
       points += 3;
   }
   else if (target->showType() == "Reptile Person")
   {
       points += 6;
   }
   else if (target->showType() == "Blue Man")
   {
       points += 9;
   }
   else if (target->showType() == "Shadow")
   {
       points += 7;
   }
}

/********************** Reptile **********************/

/* Default constructor for the Reptile derived class. */
Reptile::Reptile() : Creature()
{
   attackDice = 3;
   attackSides = 6;
   defenseDice = 1;
   defenseSides = 6;
   armor = 7;
   maxStrength = 18;
   strength = 18;
   points = 0;
   isGoblin = false;
   type = "Reptile Person";
}

/* Constructor for the Reptile derived class that takes a name as a string and
   a team name as a string. */
Reptile::Reptile(string inputName, string teamName) : Creature()
{
   attackDice = 3;
   attackSides = 6;
   defenseDice = 1;
   defenseSides = 6;
   armor = 7;
   maxStrength = 18;
   strength = 18;
   points = 0;
   isGoblin = false;
   type = "Reptile Person";
   name = inputName;
   team = teamName;
}

/* addPoints() function for the Reptile derived class. */
void Reptile::addPoints(Creature* target)
{
   if (target->showType() == "Goblin")
   {
       points += 1;
   }
   else if (target->showType() == "Barbarian")
   {
       points += 2;
   }
   else if (target->showType() == "Reptile Person")
   {
       points += 3;
   }
   else if (target->showType() == "Blue Man")
   {
       points += 5;
   }
   else if (target->showType() == "Shadow")
   {
       points += 3;
   }
}

/********************** BlueMen **********************/

/* Default constructor for the BlueMen derived class. */
BlueMen::BlueMen() : Creature()
{
   attackDice = 2;
   attackSides = 10;
   defenseDice = 3;
   defenseSides = 6;
   armor = 3;
   maxStrength = 12;
   strength = 12;
   points = 0;
   isGoblin = false;
   type = "Blue Man";
}

/* Constructor for the BlueMen derived class that takes a name as a string and
   a team name as a string. */
BlueMen::BlueMen(string inputName, string teamName) : Creature()
{
   attackDice = 2;
   attackSides = 10;
   defenseDice = 3;
   defenseSides = 6;
   armor = 3;
   maxStrength = 12;
   strength = 12;
   points = 0;
   isGoblin = false;
   type = "Blue Man";
   name = inputName;
   team = teamName;
}

/* addPoints() function for the BlueMen derived class.*/
void BlueMen::addPoints(Creature* target)
{
   if (target->showType() == "Goblin")
   {
       points += 1;
   }
   else if (target->showType() == "Barbarian")
   {
       points += 1;
   }
   else if (target->showType() == "Reptile Person")
   {
       points += 2;
   }
   else if (target->showType() == "Blue Man")
   {
       points += 3;
   }
   else if (target->showType() == "Shadow")
   {
       points += 2;
   }
}

/********************** Shadow **********************/

/* Default constructor for the Shadow derived class. */
Shadow::Shadow() : Creature()
{
   attackDice = 2;
   attackSides = 10;
   defenseDice = 1;
   defenseSides = 6;
   armor = 0;
   maxStrength = 12;
   strength = 12;
   points = 0;
   isGoblin = false;
   type = "Shadow";
}

/* Constructor for the Shadow derived class that takes a name as a string and
   a team name as a string. */
Shadow::Shadow(string inputName, string teamName) : Creature()
{
   attackDice = 2;
   attackSides = 10;
   defenseDice = 1;
   defenseSides = 6;
   armor = 0;
   maxStrength = 12;
   strength = 12;
   points = 0;
   isGoblin = false;
   type = "Shadow";
   name = inputName;
   team = teamName;
}

/* defense() function for the Shadow derived class. */
int Shadow::defense()
{
   int dodge = rand() % 2;
   if (dodge == 1)
   {
       return 0;
   }
   else
   {
       int defenseSum = 0;
       for (int i = 0; i < defenseDice; i++)
       {
           defenseSum += rand() % defenseSides + 1;
       }
       return defenseSum;
   }
}

/* addPoints() function for the Shadow derived class. */
void Shadow::addPoints(Creature* target)
{
   if (target->showType() == "Goblin")
   {
       points += 1;
   }
   else if (target->showType() == "Barbarian")
   {
       points += 2;
   }
   else if (target->showType() == "Reptile Person")
   {
       points += 3;
   }
   else if (target->showType() == "Blue Man")
   {
       points += 6;
   }
   else if (target->showType() == "Shadow")
   {
       points += 3;
   }
}

creature.h
#ifndef CREATURE_H
#define CREATURE_H

#include <string>
using std::string;

/* The class Creature is an abstract class with pure virtual functions. */
class Creature
{
public:
   Creature();
   // ~Creature();
   void combatTurn(Creature* attacker, Creature* defender);
   void regainStrength();
   // pure virtual function; redefined for every derived class
   virtual void addPoints(Creature* target) = 0;
   int showAttackDice();
   int showAttackSides();
   int showDefenseDice();
   int showDefenseSides();
   int showArmor();
   int showMaxStrength();
   int showStrength();
   int showPoints();
   string showType();
   string showName();
   string showTeam();
   bool showIsGoblin();
   bool isAlive();
   void setAttackSides(int value);
   void setName(string inputName);
protected:
   // redefined for Goblin derived class
   virtual int attack(Creature* target);
   // redefined for Shadow derived class
   virtual int defense();
   int attackDice;
   int attackSides;
   int defenseDice;
   int defenseSides;
   int armor;
   int maxStrength;
   int strength;
   int health;
   bool isGoblin;
   string type;
   string name;
   int points;
   string team;
};

class Goblin : public Creature
{
public:
   Goblin();
   Goblin(string inputName, string teamName);
private:
   virtual int attack(Creature* target);
   virtual void addPoints(Creature* target);

};

class Barbarian : public Creature
{
public:
   Barbarian();
   Barbarian(string inputName, string teamName);
   virtual void addPoints(Creature* target);
};

class Reptile : public Creature
{
public:
   Reptile();
   Reptile(string inputName, string teamName);
   virtual void addPoints(Creature* target);
};

class BlueMen : public Creature
{
public:
   BlueMen();
   BlueMen(string inputName, string teamName);
   virtual void addPoints(Creature* target);
};

class Shadow : public Creature
{
public:
   Shadow();
   Shadow(string inputName, string teamName);
private:
   virtual int defense();
   virtual void addPoints(Creature* target);
};

#endif