Hello. I basically have this code.2 fighters fight with their own attributes. Problem is that there are a few bugs in it. I want you to fix it. If I remember correctly, it had 2 or 3 bugs. Its c++ and I want it to work in visual studio. Just make sure it works. I want to send the code but unfortunately its more than 5000 words so just zoom in the picture.            Basically this is a simple bug fix.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Hello. I basically have this code.2 fighters fight with their own attributes. Problem is that there are a few bugs in it. I want you to fix it. If I remember correctly, it had 2 or 3 bugs. Its c++ and I want it to work in visual studio. Just make sure it works. I want to send the code but unfortunately its more than 5000 words so just zoom in the picture. 

 

 

 

 

 

Basically this is a simple bug fix.

#include<iostream>
#include<cstdlib>
#include<string>
#include<time.h>
using namespace std;
7:30
class AttackInfo{
public:
};
class BaseCharacter{
private:
int dmg;
string description;
AttackInfo(){}
AttackInfo(int a, string b){
dmg = a;
description = b;
}
public:
int strength,agility,intelligence, baseDamage;
public:
string name;
int maxHP,presentHP,dodgeChance;
g){
};
BaseCharacter(){
BaseCharacter(string a, int b, int c, int d, int e, int f, int g){
}
};
AttackInfo primaryAttack(){
return Attackinfo(baseDamage,"strikes at");
}
g){
name = a;
strength = b;
agility = c;
intelligence = d;
AttackInfo secondaryAttack(){
return AttackInfo(baseDamage,"");
}
maxHP = e;
presentHP = maxHP;
dodgeChance = f;
baseDamage=g;
AttackInfo getAttack(){
return primaryAttack();
7:30
}
void takeDamage(int a){}
}
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());
};
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;
at");
}
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;}
}
AttackInfo secondaryAttack(){
int a = getDodgeChance();
if(a<50)
a+=(agility/2);
setDodgeChance(a);
AttackInfo primaryAttack(){
return Attackinfo(baseDamage+baseDamage*(strength/20),"strikes
7:30
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();
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());
AttackInfo getAttack(){
srand(time(0));
int a = 1+ (rand() % 10);
if (a<=3)
return secondaryAttack();
else
return primaryAttack();
};
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,
}
void takeDamage(int a){
int b = getPresentHP();
b -= a;
setPresentHP(b);
Present HP: "+to_string(get PresentHP())+"Dodge Chance:
"+to_string(get DodgeChance());
}
AttackInfo secondaryAttack(){
return AttackInfo(baseDamage+baseDamage*(intelligence/20),"throws
a fireball at");
}
|||
7:30
AttackInfo secondaryAttack(){
int a = getPresentHP();
a += 5
setPresentHP(a);
+ (intelligence/20);
return Attackinfo(0,"heals themselves and smiles at");
}
string toString(){
return "Name: "+getName()+"Max HP: "+to_string(getMaxHp())+"
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,
AttackInfo getAttack(){
srand(time(0));
int a = 1+ (rand() % 10);
if (a<=4)
return secondaryAttack();
else
return primaryAttack();
return AttackInfo(0,"heals themselves and smiles at");
}
}
void takeDamage(int a){
int
b ==
b = getPresentHP();
a;
setPresentHP(b);
public:
Present HP: "+to_string(get PresentHP())+"Dodge Chance:
"+to_string(get DodgeChance());
}
class ArenaManager{
private:
|||
BaseCharacter *contestantList;
int maxContestant;
int numContestant;
7:31
}
string toString(){
return "Name: "+getName()+"Max HP: "+to_string(getMaxHp())+"
numContestant+=1;
return true;
if(type=='w')
ArenaManager(int a): contestantList(new BaseCharacter[a]){
maxContestant = a;
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) };
else if(type=='p')
BaseCharacter *contestantList[numContestant] = { new
Priest(a,b,c,d,e,f,g) };
else
return false;
BaseCharacter viewContestant(int a){
return contestantList[a-1];
}
void simulateChallenge(int a, int b){
|||
}
}
}
bool addContestant(char type, string a, int b, int c, int d, int e, int f, int g, int
h){
srand(time(0));
int x = 1+ (rand() % 10);
BaseCharacter attacker,counterattacker;
if(x<=5){
attacker = contestantList[a-1];
counterattacker = contestantList[b-1];
while(1){
cout
cout
7:31
}
else{
attacker = contestantList[b-1];
counterattacker = contestantList[a-1];
if(type=='w')
BaseCharacter *contestantList[numContestant] = { new
Warrior(a,b,c,d,e,f,g,h) };
else
return false;
numContestant+=1;
return true;
}
counterattacker.getName() << endl;
bool addContestant(char type, string a, int b, int c, int d, int e, int f, int g, int
h){
AttackInfo a1,a2;
<< attacker.toString() << endl;
<< counterattacker.toString() << endl;
a1 = attacker.getAttack();
cout
}
attacker.getName() << endl;
●
7:31
counterattacker.takeDamage(a1.dmg);
<< attacker.getName() <<" " << a1.description <<
if(counterattacker.getPresentHP()<=0){
cout << attacker.getName() << " wins!!!" << endl;
break;
}
string viewAllContestants(){
|||
}
return a;
string viewAllContestants(){
string
a;
for(int i=0; i<numContestant; i++){
a+=to_string(i)+""+contestantList[i].toString()+"\n";
}
a2 = counterattacker.getAttack();
cout << counterattacker.getName() <<" " << a2.description << "
attacker.takeDamage(a2.dmg);
if(attacker.getPresentHP() <=0){
cout << counterattacker.getName() << " wins!!!" << endl;
break;
B
<< "1. Warrior\n2. Mage\n3. Priest" << endl;
string
a;
cout
cin >> a;
cout
<< endl;
cin >>
b;
cout
cin >> c;
int b,c,d,e,f,g,h;
<< "Name: " << endl;
<< "Strenght: "
<< "Agility: " << endl;
<< "Intelligence:
<< "Max HP: " << endl;
<< "Dodge CHance: << endl;
<< "Base Damage:
cout
" << endl;
cin >> d;
cout
cin >> e;
cout
"
cin >>
f;
cout
"
<< endl;
cin >>
g;
if(option2==1){
<< "Resistance: " << endl;
ar.addContestant('w',a,b,c,d,e,f,g,h);
cout
cin >> h;
}
else if(option2==2)
else if(option2==3)
}
else if(option==2){
ar.addContestant('m',a,b,c,d,e,f,g,h);
ar.addContestant('p',a,b,c,d,e,f,g,h);
<<
8
cout << ar.viewAllContestants() << endl;
int option2;
cin >> option2;
}
else if(option==3){
|||
cin >> option;
if(option==1){
}
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
cin >> option2;
BaseCharacter temp = ar.viewContestant (option2);
cout << temp.toString() << endl;
int option2;
cout
cin >> option2;
<< "1. Warrior\n2. Mage\n3. Priest" << endl;
string
a;
int b,c,d,e,f,g,h;
cout
cout
cin >>
b;
cout
<< "Name: " << endl;
cin >> a;
<< "Strenght: " << endl;
<< "Agility: " << endl;
cin >> c;
<< "Intelligence: " << endl;
d;
<< "Max HP: " << endl;
" << endl;
cout
cin >>
cout
cin >>
e;
cout
CHance:
cin >>
cout
cin >>
f;
till 17% 1
"Dodge
<< "Base Damage: "
cout
cin >>
g;
if(option2==1){
<< "Resistance: " << endl;
h;
ar.addContestant('w',a,b,c,d,e,f,g,h);
ll 17% 1
5 || 17% 2
}
else if(option2==2)
else if(option2==3)
}
else if(option==2){
ar.addContestant('m',a,b,c,d,e,f,g,h);
ar.addContestant('p',a,b,c,d,e,f,g,h);
K
<< endl;
}while(option!=5);
cout << ar.viewAllContestants() << endl;
int option2;
cin >> option2;
|||
<
** || 17% 2
8
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);
...
:
till 17% £
5 || 17% 2
K
●●●
...
ll 17% 1
●●●
Transcribed Image Text:#include<iostream> #include<cstdlib> #include<string> #include<time.h> using namespace std; 7:30 class AttackInfo{ public: }; class BaseCharacter{ private: int dmg; string description; AttackInfo(){} AttackInfo(int a, string b){ dmg = a; description = b; } public: int strength,agility,intelligence, baseDamage; public: string name; int maxHP,presentHP,dodgeChance; g){ }; BaseCharacter(){ BaseCharacter(string a, int b, int c, int d, int e, int f, int g){ } }; AttackInfo primaryAttack(){ return Attackinfo(baseDamage,"strikes at"); } g){ name = a; strength = b; agility = c; intelligence = d; AttackInfo secondaryAttack(){ return AttackInfo(baseDamage,""); } maxHP = e; presentHP = maxHP; dodgeChance = f; baseDamage=g; AttackInfo getAttack(){ return primaryAttack(); 7:30 } void takeDamage(int a){} } 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()); }; 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; at"); } 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;} } AttackInfo secondaryAttack(){ int a = getDodgeChance(); if(a<50) a+=(agility/2); setDodgeChance(a); AttackInfo primaryAttack(){ return Attackinfo(baseDamage+baseDamage*(strength/20),"strikes 7:30 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(); 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()); AttackInfo getAttack(){ srand(time(0)); int a = 1+ (rand() % 10); if (a<=3) return secondaryAttack(); else return primaryAttack(); }; 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, } void takeDamage(int a){ int b = getPresentHP(); b -= a; setPresentHP(b); Present HP: "+to_string(get PresentHP())+"Dodge Chance: "+to_string(get DodgeChance()); } AttackInfo secondaryAttack(){ return AttackInfo(baseDamage+baseDamage*(intelligence/20),"throws a fireball at"); } ||| 7:30 AttackInfo secondaryAttack(){ int a = getPresentHP(); a += 5 setPresentHP(a); + (intelligence/20); return Attackinfo(0,"heals themselves and smiles at"); } string toString(){ return "Name: "+getName()+"Max HP: "+to_string(getMaxHp())+" 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, AttackInfo getAttack(){ srand(time(0)); int a = 1+ (rand() % 10); if (a<=4) return secondaryAttack(); else return primaryAttack(); return AttackInfo(0,"heals themselves and smiles at"); } } void takeDamage(int a){ int b == b = getPresentHP(); a; setPresentHP(b); public: Present HP: "+to_string(get PresentHP())+"Dodge Chance: "+to_string(get DodgeChance()); } class ArenaManager{ private: ||| BaseCharacter *contestantList; int maxContestant; int numContestant; 7:31 } string toString(){ return "Name: "+getName()+"Max HP: "+to_string(getMaxHp())+" numContestant+=1; return true; if(type=='w') ArenaManager(int a): contestantList(new BaseCharacter[a]){ maxContestant = a; 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) }; else if(type=='p') BaseCharacter *contestantList[numContestant] = { new Priest(a,b,c,d,e,f,g) }; else return false; BaseCharacter viewContestant(int a){ return contestantList[a-1]; } void simulateChallenge(int a, int b){ ||| } } } bool addContestant(char type, string a, int b, int c, int d, int e, int f, int g, int h){ srand(time(0)); int x = 1+ (rand() % 10); BaseCharacter attacker,counterattacker; if(x<=5){ attacker = contestantList[a-1]; counterattacker = contestantList[b-1]; while(1){ cout cout 7:31 } else{ attacker = contestantList[b-1]; counterattacker = contestantList[a-1]; if(type=='w') BaseCharacter *contestantList[numContestant] = { new Warrior(a,b,c,d,e,f,g,h) }; else return false; numContestant+=1; return true; } counterattacker.getName() << endl; bool addContestant(char type, string a, int b, int c, int d, int e, int f, int g, int h){ AttackInfo a1,a2; << attacker.toString() << endl; << counterattacker.toString() << endl; a1 = attacker.getAttack(); cout } attacker.getName() << endl; ● 7:31 counterattacker.takeDamage(a1.dmg); << attacker.getName() <<" " << a1.description << if(counterattacker.getPresentHP()<=0){ cout << attacker.getName() << " wins!!!" << endl; break; } string viewAllContestants(){ ||| } return a; string viewAllContestants(){ string a; for(int i=0; i<numContestant; i++){ a+=to_string(i)+""+contestantList[i].toString()+"\n"; } a2 = counterattacker.getAttack(); cout << counterattacker.getName() <<" " << a2.description << " attacker.takeDamage(a2.dmg); if(attacker.getPresentHP() <=0){ cout << counterattacker.getName() << " wins!!!" << endl; break; B << "1. Warrior\n2. Mage\n3. Priest" << endl; string a; cout cin >> a; cout << endl; cin >> b; cout cin >> c; int b,c,d,e,f,g,h; << "Name: " << endl; << "Strenght: " << "Agility: " << endl; << "Intelligence: << "Max HP: " << endl; << "Dodge CHance: << endl; << "Base Damage: cout " << endl; cin >> d; cout cin >> e; cout " cin >> f; cout " << endl; cin >> g; if(option2==1){ << "Resistance: " << endl; ar.addContestant('w',a,b,c,d,e,f,g,h); cout cin >> h; } else if(option2==2) else if(option2==3) } else if(option==2){ ar.addContestant('m',a,b,c,d,e,f,g,h); ar.addContestant('p',a,b,c,d,e,f,g,h); << 8 cout << ar.viewAllContestants() << endl; int option2; cin >> option2; } else if(option==3){ ||| cin >> option; if(option==1){ } 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 cin >> option2; BaseCharacter temp = ar.viewContestant (option2); cout << temp.toString() << endl; int option2; cout cin >> option2; << "1. Warrior\n2. Mage\n3. Priest" << endl; string a; int b,c,d,e,f,g,h; cout cout cin >> b; cout << "Name: " << endl; cin >> a; << "Strenght: " << endl; << "Agility: " << endl; cin >> c; << "Intelligence: " << endl; d; << "Max HP: " << endl; " << endl; cout cin >> cout cin >> e; cout CHance: cin >> cout cin >> f; till 17% 1 "Dodge << "Base Damage: " cout cin >> g; if(option2==1){ << "Resistance: " << endl; h; ar.addContestant('w',a,b,c,d,e,f,g,h); ll 17% 1 5 || 17% 2 } else if(option2==2) else if(option2==3) } else if(option==2){ ar.addContestant('m',a,b,c,d,e,f,g,h); ar.addContestant('p',a,b,c,d,e,f,g,h); K << endl; }while(option!=5); cout << ar.viewAllContestants() << endl; int option2; cin >> option2; ||| < ** || 17% 2 8 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); ... : till 17% £ 5 || 17% 2 K ●●● ... ll 17% 1 ●●●
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY