Exercise: Adapter Patterns
Test your understanding of the adapter design pattern by implementing it through delegation.
We'll cover the following
Problem statement
You’re given a LegacyRectangle
class, which has an oldDraw()
method. For the sake of the challenge, you can assume that your client is unable to interact with the oldDraw()
method directly. Your task is to write the code inside the RectangleAdapter
that will work as an adapter between the client code and the LegacyRectangle
's oldDraw()
method.
Coding challenge
Try to solve this question on your own, but if you’re unsure about how to do it, you can refer to this
Get hands-on with 1400+ tech skills courses.