Solution Review: Implement Getter Methods

This lesson gives the solution to the previous exercise - implementing the getter methods to calculate the width and height of a rectangle.

We'll cover the following


The getter methods are written in the lines 11-15 in the following code playground. The width() and height() methods simply subtract the x and y coordinates respectively and return the result.

This solution is illustrated in the following figure:

Get hands-on with 1000+ tech skills courses.