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

  1. Begin by examining the existing Car, Sedan, SUV, Remote, BasicRemote, AdvancedRemote, and Client classes.

  2. Update the Car interface and its implementing classes (Sedan and SUV) to include a method for starting the engine. The method should print a message indicating that the engine is starting.

  3. Update the Remote abstract class and its subclasses (BasicRemote and AdvancedRemote) to include a "startEngine" method.

  4. In the AdvancedRemote class, enhance the startEngine method to print an additional message before starting the engine.

  5. Update the Client class to demonstrate the use of the new "startEngine" method for both the BasicRemote and AdvancedRemote classes.

  6. 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.