Question: EXERCISE C Implement methods enterEvent () in Villagers, Police and Mayor class. And canDisableAlarm() in Chief class as follows: PART 1 enterEvent() : Villagers can

EXERCISE C

Implement methods enterEvent() in Villagers, Police and Mayor class. And canDisableAlarm() in Chief class as follows:

PART 1

enterEvent():

  1. Villagers can only enter the Party event
  2. Police can only enter the Party and PDMeeting events
  3. Mayor can enter the Party, PDMeeting and Presidential Reunion events

PART 2

canDisableAlarm():

  1. Only the chief can disable the alarm

See the method comments in the code base for more details about how these methods work.

You MAY NOT declare any methods that could be inherited from super classes unless they must be overriden to achieve different behavior.

test result
Villager *v = new Villager("Alberto", 72, 100, "BlackSmithShop"); cout << v->canEnterEvent("Party") << endl; cout << v->canEnterEvent("PDMeeting") << endl; cout << v->canEnterEvent("Presidential Reunion") << endl;
true false false
Villager *v1 = new Villager("Tato", 60, 100, "PizzaPlace"); Villager v2 = Villager("David", 61, 100, "PizzaPlace"); Player *v3 = new Villager("Jaime", 62, 100, "PizzaPlace"); Villager *v4 = new Villager("Alberto", 63, 100, "PizzaPlace"); Chief *c = new Chief("Harry", 61, 100, 5); cout << (v1->canDisableAlarm()) << endl; cout << (v2.canDisableAlarm()) << endl; cout << (v3->canDisableAlarm()) << endl; cout << (v4->canDisableAlarm()) << endl; cout << (c->canDisableAlarm()) << endl;
false false false false true

#include "VillageQ3.cpp"

/* * EXERCISE C PART 1-a * * Override object's method (canEnterEvent) considering * the parameter's type string * Villager's can only enter the "Party" event */

bool Villager::canEnterEvent(string event) { //Implement here!

return false; //Dummy Return }

/* * EXERCISE C PART 1-b * * Override object's method canEnterEvent considering * the parameter event string * Police can only enter the "Party" and "PDMeeting" events */

bool Police::canEnterEvent(string event) { //Implement here!

return false; //Dummy Return }

/* * EXERCISE C PART 1-c * * Override object's method canEnterEvent considering * the parameter event string. * Mayor can enter the Party, PDMeeting and Presidential Reunion events. */

bool Mayor::canEnterEvent(string event) { //Implement here!

return false; //Dummy Return }

/* * EXERCISE C PART 2 * * Create and Override the canDisableAlarm method in the Chief class to * return true. Remember that only a Chief can disable alarms. */

bool Chief::canDisableAlarm() { //--->>> Implement here! <<<--- return false; // Dummy return }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!