Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Step: 3

blur-text-image

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

Managing Your Information How To Design And Create A Textual Database On Your Microcomputer

Authors: Tenopir, Carol, Lundeen, Gerald

1st Edition

1555700233, 9781555700232

More Books

Students also viewed these Databases questions

Question

=+What is the nature of the plant or site-level role of unions?

Answered: 1 week ago

Question

=+such as the dirigenti in Italy?

Answered: 1 week ago