#include #include #include #include using namespace std; class AttackInfo{ public: int dmg; string description; AttackInfo() AttackInfo(int a, string b){ } class BaseCharacter{ private: string name; int maxHP,presentHP,dodgeChance; public: int strength, agility,intelligence,baseDamage; public: dmg = a; description = b; BaseCharacter() { BaseCharacter(string a, int b, int c, int d, int e, int f, int g name = a; strength = b; agility = c; intelligence = d; maxHP = e; presentHP = maxHP; dodgeChance = f; baseDamage=g; } AttackInfo primaryAttack(){ return AttackInfo(baseDamage,"strikes at"); } AttackInfo secondaryAttack(){ return Attackinfo(baseDamage,""); } AttackInfo getAttack(){ return primaryAttack(); } void takeDamage(int a){} string toString(){ return "Name: "+getName()+"Max HP: "+to_string(ge Present HP: "+to_string(get PresentHP())+"Dodge Chance: "+to_string(get Dodge Chance()); } string getName(){return name;} int getMaxHp(){return maxHP;} int getPresentHP(){return presentHP;} void setPresentHP(int a){presentHP=a;} int getDodgeChance(){return dodgeChance;} void setDodgeChance(int a){dodgeChance=a;} }; class Warrior: public BaseCharacter{ private: int resistance; public: Warrior(string a, int b, int c, int d, int e, int f, int g, int h):BaseCharacter(a,b,c,d,e,f,g){ resistance = h; } AttackInfo primaryAttack(){ return Attackinfo(baseDamage+baseDamage*(stren at"); } AttackInfo secondaryAttack(){ int a = getDodgeChance(); if(a<50) a+=(agility/2); setDodgeChance(a); return AttackInfo(2,"gets more agile and leaps at"); } AttackInfo getAttack(){ srand(time(0)); int a = 1+ (rand() % 10); if (a==1) return secondaryAttack(); else return primaryAttack(); }
#include #include #include #include using namespace std; class AttackInfo{ public: int dmg; string description; AttackInfo() AttackInfo(int a, string b){ } class BaseCharacter{ private: string name; int maxHP,presentHP,dodgeChance; public: int strength, agility,intelligence,baseDamage; public: dmg = a; description = b; BaseCharacter() { BaseCharacter(string a, int b, int c, int d, int e, int f, int g name = a; strength = b; agility = c; intelligence = d; maxHP = e; presentHP = maxHP; dodgeChance = f; baseDamage=g; } AttackInfo primaryAttack(){ return AttackInfo(baseDamage,"strikes at"); } AttackInfo secondaryAttack(){ return Attackinfo(baseDamage,""); } AttackInfo getAttack(){ return primaryAttack(); } void takeDamage(int a){} string toString(){ return "Name: "+getName()+"Max HP: "+to_string(ge Present HP: "+to_string(get PresentHP())+"Dodge Chance: "+to_string(get Dodge Chance()); } string getName(){return name;} int getMaxHp(){return maxHP;} int getPresentHP(){return presentHP;} void setPresentHP(int a){presentHP=a;} int getDodgeChance(){return dodgeChance;} void setDodgeChance(int a){dodgeChance=a;} }; class Warrior: public BaseCharacter{ private: int resistance; public: Warrior(string a, int b, int c, int d, int e, int f, int g, int h):BaseCharacter(a,b,c,d,e,f,g){ resistance = h; } AttackInfo primaryAttack(){ return Attackinfo(baseDamage+baseDamage*(stren at"); } AttackInfo secondaryAttack(){ int a = getDodgeChance(); if(a<50) a+=(agility/2); setDodgeChance(a); return AttackInfo(2,"gets more agile and leaps at"); } AttackInfo getAttack(){ srand(time(0)); int a = 1+ (rand() % 10); if (a==1) return secondaryAttack(); else return primaryAttack(); }
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
![#include<iostream>
#include<cstdlib>
#include<string>
#include<time.h>
using namespace std;
class AttackInfo{
public:
};
int dmg;
string description;
AttackInfo()
AttackInfo(int a, string b){
dmg = a;
description = b;
class BaseCharacter{
private:
}
string name;
int maxHP,presentHP,dodgeChance;
public:
int strength, agility,intelligence, baseDamage;
public:
BaseCharacter() {
BaseCharacter(string a, int b, int c, int d, int e, int f, int g){
name = a;
strength = b;
agility = c;
intelligence = d;
maxHP = e;
presentHP = maxHP;
dodgeChance = f;
baseDamage=g;
}
AttackInfo primaryAttack(){
return AttackInfo(baseDamage,"strikes at");
}
at");
AttackInfo secondaryAttack(){
return AttackInfo(baseDamage,"");
}
}
void takeDamage(int a){}
string toString(){
return "Name: "+getName()+"Max HP: "+to_string(getMaxHp())+"
Present HP: "+to_string(getPresentHP())+"Dodge Chance:
"+to_string(get DodgeChance());
}
};
AttackInfo getAttack(){
return primaryAttack();
};
class Warrior: public BaseCharacter{
private:
string getName(){return name;}
int getMaxHp(){return maxHP;}
int getPresentHP(){return presentHP;}
void setPresentHP(int a){presentHP=a;}
int getDodgeChance(){return dodgeChance;}
void setDodgeChance(int a){dodgeChance=a;}
int resistance;
public:
Warrior(string a, int b, int c, int d, int e, int f, int g, int
h):BaseCharacter(a,b,c,d,e,f,g){
resistance = h;
}
AttackInfo primaryAttack(){
return AttackInfo(baseDamage+baseDamage*(strength/20),"strikes
}
AttackInfo secondaryAttack(){
int a = getDodge Chance();
if(a<50)
a+=(agility/2);
setDodgeChance(a);
return AttackInfo(2,"gets more agile and leaps at");
}
AttackInfo getAttack(){
srand(time(0));
int a = 1+ (rand() % 10);
if (a==1)
return secondaryAttack();
else
return primaryAttack();
}
void takeDamage(int a){
int b = getPresentHP();
b -= a;
setPresentHP(b);
}
string toString(){
return "Name: "+getName()+"Max HP: "+to_string(getMaxHp())+"
Present HP: "+to_string(get PresentHP()+"Dodge Chance:
"+to_string(get DodgeChance());
}
};
class Mage: public BaseCharacter{
public:
Mage(string a, int b, int c, int d, int e, int f, int g):BaseCharacter(a,b,c,d,e,f,
g){
AttackInfo secondaryAttack(){
return
a fireball at");
}
Attackinfo(baseDamage+baseDamage*(intelligence/20),"throws
AttackInfo getAttack(){
srand(time(0));
int a = 1+ (rand() % 10);
if (a<=3)
return secondaryAttack();
else
return primaryAttack();
}
void takeDamage(int a){
int b = getPresentHP();
b = a;
setPresentHP(b);
}
string toString(){
return "Name: "+getName()+"Max HP: "+to_string(getMaxHp())+"
Present HP: "+to_string(getPresentHP())+"Dodge Chance:
"+to_string(get DodgeChance());
}
};
class Priest: public BaseCharacter{
public:
Priest(string a, int b, int c, int d, int e, int f, int g):BaseCharacter(a,b,c,d,e,f,
g){
AttackInfo secondaryAttack(){
int a = getPresentHP();
a += 5+ (intelligence/20);
setPresentHP(a);
return Attackinfo(0,"heals themselves and smiles at");
}
AttackInfo getAttack(){
srand(time(0));
int a = 1+ (rand() % 10);
if (a<=4)
return secondaryAttack();
else
return primaryAttack();
}
void takeDamage(int a){
int b = getPresentHP();
b -= a;
setPresentHP(b);
}
string toString(){
return "Name: "+getName()+"Max HP: "+to_string(getMaxHp())+"
Present HP: "+to_string(getPresentHP())+"Dodge Chance:
"+to_string(get DodgeChance());
}](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Ff3d14749-a37f-49b6-af18-abad2bb46604%2F29b64713-967b-42bd-bade-3e07e9ab9680%2F2px2jic_processed.jpeg&w=3840&q=75)
Transcribed Image Text:#include<iostream>
#include<cstdlib>
#include<string>
#include<time.h>
using namespace std;
class AttackInfo{
public:
};
int dmg;
string description;
AttackInfo()
AttackInfo(int a, string b){
dmg = a;
description = b;
class BaseCharacter{
private:
}
string name;
int maxHP,presentHP,dodgeChance;
public:
int strength, agility,intelligence, baseDamage;
public:
BaseCharacter() {
BaseCharacter(string a, int b, int c, int d, int e, int f, int g){
name = a;
strength = b;
agility = c;
intelligence = d;
maxHP = e;
presentHP = maxHP;
dodgeChance = f;
baseDamage=g;
}
AttackInfo primaryAttack(){
return AttackInfo(baseDamage,"strikes at");
}
at");
AttackInfo secondaryAttack(){
return AttackInfo(baseDamage,"");
}
}
void takeDamage(int a){}
string toString(){
return "Name: "+getName()+"Max HP: "+to_string(getMaxHp())+"
Present HP: "+to_string(getPresentHP())+"Dodge Chance:
"+to_string(get DodgeChance());
}
};
AttackInfo getAttack(){
return primaryAttack();
};
class Warrior: public BaseCharacter{
private:
string getName(){return name;}
int getMaxHp(){return maxHP;}
int getPresentHP(){return presentHP;}
void setPresentHP(int a){presentHP=a;}
int getDodgeChance(){return dodgeChance;}
void setDodgeChance(int a){dodgeChance=a;}
int resistance;
public:
Warrior(string a, int b, int c, int d, int e, int f, int g, int
h):BaseCharacter(a,b,c,d,e,f,g){
resistance = h;
}
AttackInfo primaryAttack(){
return AttackInfo(baseDamage+baseDamage*(strength/20),"strikes
}
AttackInfo secondaryAttack(){
int a = getDodge Chance();
if(a<50)
a+=(agility/2);
setDodgeChance(a);
return AttackInfo(2,"gets more agile and leaps at");
}
AttackInfo getAttack(){
srand(time(0));
int a = 1+ (rand() % 10);
if (a==1)
return secondaryAttack();
else
return primaryAttack();
}
void takeDamage(int a){
int b = getPresentHP();
b -= a;
setPresentHP(b);
}
string toString(){
return "Name: "+getName()+"Max HP: "+to_string(getMaxHp())+"
Present HP: "+to_string(get PresentHP()+"Dodge Chance:
"+to_string(get DodgeChance());
}
};
class Mage: public BaseCharacter{
public:
Mage(string a, int b, int c, int d, int e, int f, int g):BaseCharacter(a,b,c,d,e,f,
g){
AttackInfo secondaryAttack(){
return
a fireball at");
}
Attackinfo(baseDamage+baseDamage*(intelligence/20),"throws
AttackInfo getAttack(){
srand(time(0));
int a = 1+ (rand() % 10);
if (a<=3)
return secondaryAttack();
else
return primaryAttack();
}
void takeDamage(int a){
int b = getPresentHP();
b = a;
setPresentHP(b);
}
string toString(){
return "Name: "+getName()+"Max HP: "+to_string(getMaxHp())+"
Present HP: "+to_string(getPresentHP())+"Dodge Chance:
"+to_string(get DodgeChance());
}
};
class Priest: public BaseCharacter{
public:
Priest(string a, int b, int c, int d, int e, int f, int g):BaseCharacter(a,b,c,d,e,f,
g){
AttackInfo secondaryAttack(){
int a = getPresentHP();
a += 5+ (intelligence/20);
setPresentHP(a);
return Attackinfo(0,"heals themselves and smiles at");
}
AttackInfo getAttack(){
srand(time(0));
int a = 1+ (rand() % 10);
if (a<=4)
return secondaryAttack();
else
return primaryAttack();
}
void takeDamage(int a){
int b = getPresentHP();
b -= a;
setPresentHP(b);
}
string toString(){
return "Name: "+getName()+"Max HP: "+to_string(getMaxHp())+"
Present HP: "+to_string(getPresentHP())+"Dodge Chance:
"+to_string(get DodgeChance());
}
![class ArenaManager{
private:
BaseCharacter *contestantList;
int maxContestant;
int numContestant;
public:
ArenaManager(int
maxContestant
numContestant = 0;
}
bool addContestant(char type, string a, int b, int c, int d, int e, int f, int g){
if(type=='m')
BaseCharacter *contestantList[numContestant] = { new
Mage(a,b,c,d,e,f,g) };
Priest(a,b,c,d,e,f,g) };
else
return false;
else if(type=='p')
BaseCharacter *contestantList[numContestant] = { new
}
bool addContestant(char type, string a, int b, int c, int d, int e, int f, int g, int
h){
}
}
numContestant+=1;
return true;
Warrior(a,b,c,d,e,f,g,h) };
else
a): contestantList(new BaseCharacter[a]){
= a;
if(type=='w')
BaseCharacter *contestantList[numContestant] = { new
return false;
numContestant+=1;
return true;
BaseCharacter viewContestant(int a){
return contestantList[a-1];
}
void simulateChallenge(int a, int b){
srand(time(0));
int x = 1+ (rand() % 10);
BaseCharacter attacker,counterattacker;
if(x<=5){
attacker = contestantList[a-1];
counterattacker = contestantList[b-1];
}
else{
}
}
attacker = contestantList[b-1];
counterattacker = contestantList[a-1];
while(1){
cout << attacker.toString() << endl;
cout << counterattacker.toString() << endl;
AttackInfo a1,a2;
counterattacker.getName() << endl;
AttackInfo a1,a2;
a1 = attacker.getAttack();
cout << attacker.getName() <<" " << a1.description << " " .
counterattacker.takeDamage(a1.dmg);
if(counterattacker.getPresentHP() <=0){
cout << attacker.getName() << "wins!!!" << endl;
break;
attacker.getName() << endl;
}
a2 = counterattacker.getAttack();
cout << counterattacker.getName() <<" " << a2.description <<
attacker.takeDamage(a2.dmg);
if(attacker.getPresentHP()<=0){
cout << counterattacker.getName() << " wins!!!" << endl;
break;
}
}
string viewAllContestants(){
string a;
for(int i=0; i<numContestant; i++){
a+=to_string(i)+"."+contestantList[i].toString()+"\n";
}
return a;
}
int main() {
int option=0;
ArenaManager ar(10);
do{
cout << "1.Add Contestant\n2. View Specific Contestant\n3. View All
Contestants\n4. Simulate Challenge\n5. Exit"<<endl;
cin >> option;
if(option==1){
int option2;
cout << "1. Warrior\n2. Mage\n3. Priest" << endl;
cin >> option2;
string a;
int b,c,d,e,f,g,h;
cout << "Name: " << endl;
cin >> a;
cout << "Strenght: " << endl;
cin >> b;
cout << "Agility: " << endl;
cin >> c;
cout << "Intelligence: " << endl;
cin >> d;
cout << "Max HP: " << endl;
cin >> e;
cout << "Dodge CHance: " << endl;
cin >> f;
cout << "Base Damage: " << endl;
cin >> g;
if(option2==1){
cout << "Resistance: " << endl;
cin >> h;
imptomi2,
cout << "1. Warrior\n2. Mage\n3. Priest" << endl;
cin >> option2;
string a;
int b,c,d,e,f,g,h;
cout << "Name: " << endl;
cin >> a;
cout << "Strenght: " << endl;
cin >> b;
cout << "Agility: " << endl;
cin >> c;
cout << "Intelligence: " << endl;
cin >> d;
cout << "Max HP: " << endl;
cin >> e;
cout << "Dodge CHance: " << endl;
cin >> f;
cout << "Base Damage: " << endl;
cin >> g;
if(option2==1){
cout << "Resistance: " << endl;
cin >> h;
ar.addContestant('w',a,b,c,d,e,f,g,h);
}
else if(option2==2)
else if(option2==3)
ar.addContestant('m',a,b,c,d,e,f,g,h);
ar.addContestant('p',a,b,c,d,e,f,g,h);
}
}
else if(option==2){
cout << ar.viewAllContestants() << endl;
int option2;
cin >> option2;
BaseCharacter temp = ar.viewContestant (option2);
cout << temp.toString() << endl;
else if(option==3){
cout << ar.viewAllContestants() << endl;
}
else if(option==4){
cout << ar.viewAllContestants() << endl;
int option2,option3;
cin >> option2;
cin >> option3;
ar.simulateChallenge(option2,option3);
}while(option!=5);
<<](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Ff3d14749-a37f-49b6-af18-abad2bb46604%2F29b64713-967b-42bd-bade-3e07e9ab9680%2F5ldr1j_processed.jpeg&w=3840&q=75)
Transcribed Image Text:class ArenaManager{
private:
BaseCharacter *contestantList;
int maxContestant;
int numContestant;
public:
ArenaManager(int
maxContestant
numContestant = 0;
}
bool addContestant(char type, string a, int b, int c, int d, int e, int f, int g){
if(type=='m')
BaseCharacter *contestantList[numContestant] = { new
Mage(a,b,c,d,e,f,g) };
Priest(a,b,c,d,e,f,g) };
else
return false;
else if(type=='p')
BaseCharacter *contestantList[numContestant] = { new
}
bool addContestant(char type, string a, int b, int c, int d, int e, int f, int g, int
h){
}
}
numContestant+=1;
return true;
Warrior(a,b,c,d,e,f,g,h) };
else
a): contestantList(new BaseCharacter[a]){
= a;
if(type=='w')
BaseCharacter *contestantList[numContestant] = { new
return false;
numContestant+=1;
return true;
BaseCharacter viewContestant(int a){
return contestantList[a-1];
}
void simulateChallenge(int a, int b){
srand(time(0));
int x = 1+ (rand() % 10);
BaseCharacter attacker,counterattacker;
if(x<=5){
attacker = contestantList[a-1];
counterattacker = contestantList[b-1];
}
else{
}
}
attacker = contestantList[b-1];
counterattacker = contestantList[a-1];
while(1){
cout << attacker.toString() << endl;
cout << counterattacker.toString() << endl;
AttackInfo a1,a2;
counterattacker.getName() << endl;
AttackInfo a1,a2;
a1 = attacker.getAttack();
cout << attacker.getName() <<" " << a1.description << " " .
counterattacker.takeDamage(a1.dmg);
if(counterattacker.getPresentHP() <=0){
cout << attacker.getName() << "wins!!!" << endl;
break;
attacker.getName() << endl;
}
a2 = counterattacker.getAttack();
cout << counterattacker.getName() <<" " << a2.description <<
attacker.takeDamage(a2.dmg);
if(attacker.getPresentHP()<=0){
cout << counterattacker.getName() << " wins!!!" << endl;
break;
}
}
string viewAllContestants(){
string a;
for(int i=0; i<numContestant; i++){
a+=to_string(i)+"."+contestantList[i].toString()+"\n";
}
return a;
}
int main() {
int option=0;
ArenaManager ar(10);
do{
cout << "1.Add Contestant\n2. View Specific Contestant\n3. View All
Contestants\n4. Simulate Challenge\n5. Exit"<<endl;
cin >> option;
if(option==1){
int option2;
cout << "1. Warrior\n2. Mage\n3. Priest" << endl;
cin >> option2;
string a;
int b,c,d,e,f,g,h;
cout << "Name: " << endl;
cin >> a;
cout << "Strenght: " << endl;
cin >> b;
cout << "Agility: " << endl;
cin >> c;
cout << "Intelligence: " << endl;
cin >> d;
cout << "Max HP: " << endl;
cin >> e;
cout << "Dodge CHance: " << endl;
cin >> f;
cout << "Base Damage: " << endl;
cin >> g;
if(option2==1){
cout << "Resistance: " << endl;
cin >> h;
imptomi2,
cout << "1. Warrior\n2. Mage\n3. Priest" << endl;
cin >> option2;
string a;
int b,c,d,e,f,g,h;
cout << "Name: " << endl;
cin >> a;
cout << "Strenght: " << endl;
cin >> b;
cout << "Agility: " << endl;
cin >> c;
cout << "Intelligence: " << endl;
cin >> d;
cout << "Max HP: " << endl;
cin >> e;
cout << "Dodge CHance: " << endl;
cin >> f;
cout << "Base Damage: " << endl;
cin >> g;
if(option2==1){
cout << "Resistance: " << endl;
cin >> h;
ar.addContestant('w',a,b,c,d,e,f,g,h);
}
else if(option2==2)
else if(option2==3)
ar.addContestant('m',a,b,c,d,e,f,g,h);
ar.addContestant('p',a,b,c,d,e,f,g,h);
}
}
else if(option==2){
cout << ar.viewAllContestants() << endl;
int option2;
cin >> option2;
BaseCharacter temp = ar.viewContestant (option2);
cout << temp.toString() << endl;
else if(option==3){
cout << ar.viewAllContestants() << endl;
}
else if(option==4){
cout << ar.viewAllContestants() << endl;
int option2,option3;
cin >> option2;
cin >> option3;
ar.simulateChallenge(option2,option3);
}while(option!=5);
<<
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education