Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Recall that we used the example of a bunch of superheroes in the last session on Creational design patterns. Let's take the same example here

Recall that we used the example of a bunch of superheroes in the last session on Creational design patterns. Let's take the same example here and try to create a Bridge pattern considering the following scenario:
Lets consider 2 superheroes for now: The Magician and Avon The Slayer. There are 3 functions that will be done by these two - Appear, Attack and Retreat. There will be 2 types of actions for each of the superheroes - AvonAction and TheMagicianAction.
There will be 3 pre-actions: onActivate, apply and onDeactivate. These 3 pre-actions will be defined for the Superhero Action class. These 3 pre-actions will define when the superhero will perfom his/her action.
You can refer the following steps to create the solution for the problem:
1. Create an interface which declares the 3 superhero actions
2. Create 2 classes: The Magician and Avon the Slayer which defines all 3 actions declared in the Revenger interface
3. Create the interface class for the Superhero Action which will declare the 3 pre-actions
4. Create the implementation of the 3 pre-actions for both the superheroes
5. Write the client code for the 3 actions

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

Students also viewed these Databases questions

Question

What is meant by organisational theory ?

Answered: 1 week ago

Question

What is meant by decentralisation of authority ?

Answered: 1 week ago

Question

Briefly explain the qualities of an able supervisor

Answered: 1 week ago

Question

Define policy making?

Answered: 1 week ago

Question

Define co-ordination?

Answered: 1 week ago

Question

4. Explain the strengths and weaknesses of each approach.

Answered: 1 week ago