Question
EXERCISE A For this first exercise, you should implement the constructor for the Chief class that extends Police. The parameters used in the Chief constructor
EXERCISE A
For this first exercise, you should implement the constructor for the Chief class that extends Police. The parameters used in the Chief constructor are: string name, int inches, int weight, int yearsInService.
For example:
test | result |
Chief* c = new Chief("Felipe", 60, 100, 20); cout << c->toString() << endl; | {Chief: Name=Felipe Height=60 Weight=100 Rank=Chief Years=20 } |
#include "VillageQ1.cpp"
/* * EXERCISE A * * Implement the Chief Class constructor by calling its super class constructor * and passing the appropriate parameters. * HINT: You use the Police class as a guide. And remember a Chief is a rank */
Chief::Chief(string name, int height, int weight, int yearsInService) : Police(NULL, 0, 0, NULL) //Dummy super constructor { //Implement here! }
___________
class Police : public Player
{
private:
const int SALARY = 50000;
string rank;
public:
Police(string name, int height, int weight, string rank) : Player(name, height, weight)
{
this->rank = rank;
}
string getRank() { return rank; }
void setRank(string rank) { this->rank = rank; }
virtual int getSalary() { return SALARY; }
virtual string toString();
virtual bool canEnterEvent(string event);
virtual string greet();
virtual bool equals(Player *p);
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started