Answered step by step
Verified Expert Solution
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 superheroes for now: The Magician and Avon The Slayer. There are functions that will be done by these two Appear, Attack and Retreat. There will be types of actions for each of the superheroes AvonAction and TheMagicianAction.
There will be preactions: onActivate, apply and onDeactivate. These preactions will be defined for the Superhero Action class. These preactions will define when the superhero will perfom hisher action.
You can refer the following steps to create the solution for the problem:
Create an interface which declares the superhero actions
Create classes: The Magician and Avon the Slayer which defines all actions declared in the Revenger interface
Create the interface class for the Superhero Action which will declare the preactions
Create the implementation of the preactions for both the superheroes
Write the client code for the actions
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