Exercise: Decorator Design Pattern
Test your understanding of decorator design patterns by adding an extra wrapper.
We'll cover the following
Problem statement
Write a BorderShape
class that inherits from the Shape
class, which will represent a shape with a border around it.
The class should have:
- A public constructor that initializes the
width
andheight
variables to the width and height of the referenced shape plus the border size. - A public override method
str()
that returns a string describing the shape, including the border size. - A public override method
getWidth()
that returns the width of the shape, including the border. - A public override method
getHeight()
that returns the height of the shape, including the border.
Coding Challenge
Get hands-on with 1400+ tech skills courses.