Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

EXERCISE B Override the getSalary() method in the Chief class by calling the super getSalary() and adding a salary bonus depending of the chief years

EXERCISE B

Override the getSalary() method in the Chief class by calling the super getSalary() and adding a salary bonus depending of the chief years in Service as follows:

  • If chief has more than 3 years and less than 5 years of service his salary will be raised 25%.
  • If chief has 5 or more years and less that 10 years of service his salary will be raised 50%.
  • If chief has 10 or more years of service his salary will be raised 75%.
  • Else the salary will not be raised.

See method comments in the code base for more details about how the method works.

test result
Chief *chief1 = new Chief("Felipe", 60, 100, 0); cout << chief1->getSalary() << endl;
50000
Chief *chief2 = new Chief("Mario", 65, 120, 1); cout << chief2->getSalary() << endl;
50000

#include "VillageQ2.cpp" /* * EXERCISE B * * Override the getSalary method in the Chief class by calling the super * getSalary method and adding the bonus times yearInService. * If chief has more than 3 years and less than 5 years of service his salary will be raised 25% * If chief has 5 years or more and less that 10 years of service his salary will be raised 50% * If chief has 10 years or more of service his salary will be raised 75% * Else the salary will not be raised. */

int Chief::getSalary() { //Implement here!

return 0; //Dummy Return }

________________________

class Chief : public Police

{

private:

int yearsInService;

public:

Chief(string name, int height, int weight, int yearsInService);

int getYearsInService() { return yearsInService; }

void setYearInService(int yearsInService) { this->yearsInService = yearsInService; }

virtual int getSalary();

virtual string toString();

virtual bool canDisableAlarm();

virtual string greet();

virtual bool equals(Player *p);

};

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

JDBC Database Programming With J2ee

Authors: Art Taylor

1st Edition

0130453234, 978-0130453235

More Books

Students also viewed these Databases questions

Question

Why is employee safety a big concern for organisations?

Answered: 1 week ago