
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question

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);
<<](https://content.bartleby.com/qna-images/question/f3d14749-a37f-49b6-af18-abad2bb46604/29b64713-967b-42bd-bade-3e07e9ab9680/5ldr1j_thumbnail.jpeg)
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

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 steps

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.Similar questions
- 1. Assume the following: class Complex{public:Complex(int, int); //initializes the private data members to the passed in values: // real = value of the first argument // imag = value of the second argumentComplex add( Complex ); //returns a Complex object that holds the sum of two //Complex objectsvoid print(); //prints the values of the private data members in the format: // (real, imag)private:int real, imag;}; Will these two lines work below in a driver program for the class? Complex c1(40,50); //create object (line 1) c1.real=55; //move in value of 55 (line 2) a. yes it will work fine b. no, you will get a compiler error c. need more information on the object d. line 1 will cause an error line 2 will work finearrow_forwardclass Airplane – highlights -- planeID : String -planeModel: String //”Boeing 757” etc. --seatCapacity : int //would vary by outfitting ………… Assume getters and setters, toString(), constructor with parameters and constructor ……………… Write lambdas using a standard functional interface to: a) Given a plane object and a required number of seats as an input, determine if the given plane meets or exceeds the required capacity b) Output the plane description if capacity is less than 80% of a specified number (We would use his for planning aircraft assigned to various routes. ) c) Adjust the seats in a plane by a specified positive or negative number [after modifications have been made to the interior.] …and write an example for each showing the usage, using an Airplane instance plane1arrow_forwardC++ Create a class named Student that has three member variables:name – A string that stores the name of the studentnumClasses – An integer that tracks how many courses the student is currently enrolledinclassList – A dynamic array of strings used to store the names of the classes that thestudent is enrolled inWrite appropriate constructor(s), mutator, and accessor methods for the class along with thefollowing: A method that inputs all values from the user, including the list of class names. Thismethod will have to support input for an arbitrary number of classes. A method that outputs the name and list of all courses. A method that resets the number of classes to 0 and the classList to an empty list. An overloaded assignment operator that correctly makes a new copy of the list ofcourses. A destructor that releases all memory that has been allocated.Write a main method that tests all of your functions.arrow_forward
- using System; class Program { publicstaticvoid Main(string[] args) { int number = 1; while (number <= 88) { Console.WriteLine(number); number = number + 2; } int[] randNo = newint[88]; Random r = new Random(); int i=0; while (number <= 88) { randNo[i] = number; number+=1; i+=1; } for (i = 0; i < 3; i++) { Console.WriteLine("Random Numbers between 1 and 88 are " + randNo[r.Next(1, 88)]); } } } this code counts from 1-88 in odds and then selects three different random numbers. it keeps choosing 0 as a random number everytime. how can that be fixed?arrow_forwardJava Programming Assignment 6 – The Web Browser Web browsers are deceptively complex programs. The simple task of opening a web page carries a lot of steps: networking calls, protocol exchanges, rendering graphics, download and storage, JavaScript functionality, etc. It’s a lot to handle. The myriad number of tasks at hand provides a great example of different situations for collecting and managing information. Perfect for trying out the Java Collections Classes. Program requirements: • Create a new class, called “WebBrowser.” Inside it, place your main program. When run, your program will ask the user for commands. The following commands should be provided: o GOTO o DOWNLOAD o BACK o FORWARD o SHOW_DOWNLOADS o CLEAR_DOWNLOADS o SHOW_HISTORY o CLEAR_HISTORY o END • For the command above, should be any user-input String in the format of a typical web address. • Inside your WebBrowser main program, create the following: o A Stack of Strings called “backwards” o A Stack…arrow_forwardMorse Code (python ) Morse code maps each letter of the alphabet to a series of dashes and dots (a = .-). The list of the Morse code for all English letters (from a to z) is provided below: [".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","- -","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.-- ","--.."] Your goal here is to implement a function that takes a list of strings as its only parameter (called “words”). Each of the words can be transformed to Morse code by concatenation of a number of the above strings (without spaces). For example, the transformation of “ab” will be “.--...” (“.-” + “-...”). The word “ems” will also have the same transformation “.--...” (“.” + “--” + “...”). In this function, the goal is to return the number of the unique transformations in “words” list. Here is an example (none of this is needed to be printed, the function will only return one integer): Words = [“ab”, “a”, “ems”]Returned value: 2Explanation:…arrow_forward
- #include <iostream>#include <cstdlib>using namespace std; class IntNode {public: IntNode(int dataInit = 0, IntNode* nextLoc = nullptr); void InsertAfter(IntNode* nodeLoc); IntNode* GetNext(); void PrintNodeData(); int GetDataVal();private: int dataVal; IntNode* nextNodePtr;}; // ConstructorIntNode::IntNode(int dataInit, IntNode* nextLoc) { this->dataVal = dataInit; this->nextNodePtr = nextLoc;} /* Insert node after this node. * Before: this -- next * After: this -- node -- next */void IntNode::InsertAfter(IntNode* nodeLoc) { IntNode* tmpNext = nullptr; tmpNext = this->nextNodePtr; // Remember next this->nextNodePtr = nodeLoc; // this -- node -- ? nodeLoc->nextNodePtr = tmpNext; // this -- node -- next} // Print dataValvoid IntNode::PrintNodeData() { cout << this->dataVal << endl;} // Grab location pointed by nextNodePtrIntNode* IntNode::GetNext() { return this->nextNodePtr;} int IntNode::GetDataVal() {…arrow_forwardC++ #include <iostream>using namespace std; //creating struct to hold //student name,age and letter gradestruct student{ //data members string name; int age; char grade;};int main(){ //declaring object for the struct student *k = new student; //filling it with data k->name = "Kate"; k->age=24; k->grade='B'; ///then printing student data cout<<"Name:"<<k->name<<endl; cout<<"Age:"<<k->age<<endl; cout<<"Grade:"<<k->grade<<endl; return 0;}arrow_forwardTrue or False _(1) The expression n/3*(8+4) evaluates to 16 if n=4 ___(2) x is greater than both y and z can be written as the statement x>y&&z ; in Java. ___(3) In Java a string is automatically an object.arrow_forward
- I need help with this PLEASE NO JAVA NO C++ ONLY PYTHON PLZ Create a class object with the following attributes and actions: Class Name Class number Classroom Semester Level Subject Actions: Store a class list Print the class list as follows: Class name Class Number Semester Level Subject Test your object: Ask the user for all the information and to enter at least 3 classes test using all the actions of the object print using the to string action Describe the numbers and text you print. Do not just print numbers or strings to the screen explain what each number represents.arrow_forwardC++arrow_forwardclass implementation file -- Rectangle.cpp class Rectangle { #include #include "Rectangle.h" using namespace std; private: double width; double length; public: void setWidth (double); void setLength (double) ; double getWidth() const; double getLength() const; double getArea () const; } ; // set the width of the rectangle void Rectangle::setWidth (double w) { width = w; } // set the length of the rectangle void Rectangle::setLength (double l) { length l; //get the width of the rectangle double Rectangle::getWidth() const { return width; // more member functions herearrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

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)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education