My professor wants us to create a gladiator simulation where we name 5 gladiator
ID: 3721839 • Letter: M
Question
My professor wants us to create a gladiator simulation where we name 5 gladiators, then create their stats, create the boss stats, then allow for the gladiators to fight the boss. During the fight, the health of everyone and randomly generated number damage dealt will be displayed until a winner is decided and from there, we will prompt the user if they would want a rematch.
Currently, I am stuck on figuring out what is and how do I use a constructor. Overall, I am lost with the project in total, but for now I want to understand this step by step. Inside the BossFight.h, consists of the prototype functions.
Explanation / Answer
here you can see and understand how you can use constructor to initializes objects : -------->>>>>>
#ifndef _BOSS_FIGHT_H_
#define _BOSS_FIGHT_H_
#define PSIZE 10
#include<iostream>
using namespace std;
class BossFight {
private:
//Holds the party of gladiators that is banded together to fight the boss
Gladiator party[PSIZE];
//Holds the powerful boss that the party is fighting
Gladiator boss;
//Variables used for record keeping
int turnNum, fightsStarted, fightsWon;
//Will fill the party with gladiators, this function can call/reuse the createGladiator function.
void getParty();
//Will generate a boss for the party to fight. Has no crit or evasion, but 3* damage min and range, and 6* health
void getBoss();
//Tells the user who won, after how many turns, and the current record for the session
void displayFightResults(bool partyWon);
//One turn occurs, where each party member attacks the boss, then the boss attacks the party.
//Returned value indicates status of fight (continue, party win, party loss)
//Boss will randomly choose between attacking a single (randomly chosen) party member for full damage, or
//attacking the full party for half damage.
int takeTurn();
//Handles dealing damage to the entire party
void bossAttacksArea();
public:
//Responsible for generating the party and the boss, should initialize the other
//private variables as well
BossFight();
//User calls this when they want to run a fight. It will ask them if they want to use
//the same party, or get a new one.
void runFight();
};class BossFight {
private:
//Holds the party of gladiators that is banded together to fight the boss
Gladiator party[PSIZE];
//Holds the powerful boss that the party is fighting
Gladiator boss;
//Variables used for record keeping
int turnNum, fightsStarted, fightsWon;
//Will fill the party with gladiators, this function can call/reuse the createGladiator function.
void getParty();
//Will generate a boss for the party to fight. Has no crit or evasion, but 3* damage min and range, and 6* health
void getBoss();
//Tells the user who won, after how many turns, and the current record for the session
void displayFightResults(bool partyWon);
//One turn occurs, where each party member attacks the boss, then the boss attacks the party.
//Returned value indicates status of fight (continue, party win, party loss)
//Boss will randomly choose between attacking a single (randomly chosen) party member for full damage, or
//attacking the full party for half damage.
int takeTurn();
//Handles dealing damage to the entire party
void bossAttacksArea();
public:
//Responsible for generating the party and the boss, should initialize the other
//private variables as well
BossFight();
//User calls this when they want to run a fight. It will ask them if they want to use
//the same party, or get a new one.
void runFight();
};
void BossFight::getParty(){
for(int i = 0;i<PSIZE;i++){
party[i] = Gladiator();//please give the appropriate constructor to initialize the party[i] object like shown here
}
}
void BossFight::getBoss(){
boss = Gladiator();//please give the appropriate constructor to initialize the boss object like shown here
}
BossFight::BossFight(){
getParty();
getBoss();
fightsStarted = 0;
fightsWon = 0;
turnNum = 0;
}
#endif
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.