Bridge Pattern Lab 1
Enhancing the Car Remote Opener Using the Bridge Pattern
Objective
In this lab, you will extend an existing application implementing the Bridge design pattern. The current application includes a Remote
class that controls a Car
. You will add a new feature to the remote: a "startEngine" method.
Instructions
Begin by examining the existing
Car
,Sedan
,SUV
,Remote
,BasicRemote
,AdvancedRemote
, andClient
classes.Update the
Car
interface and its implementing classes (Sedan
andSUV
) to include a method for starting the engine. The method should print a message indicating that the engine is starting.Update the
Remote
abstract class and its subclasses (BasicRemote
andAdvancedRemote
) to include a "startEngine" method.In the
AdvancedRemote
class, enhance thestartEngine
method to print an additional message before starting the engine.Update the
Client
class to demonstrate the use of the new "startEngine" method for both theBasicRemote
andAdvancedRemote
classes.Test your application to ensure that it behaves as expected.
Bonus
If you have extra time, consider these additional tasks:
Add another type of car to your application (like a Truck) and modify your
Car
interface to handle this new type.Add additional features to your remotes, like a method to unlock the trunk.
Tips
Remember that the Bridge pattern should be used when you want to avoid a permanent binding between an abstraction and its implementation. This might be the case when the implementation must be selected or switched at run-time.