Solution Review: Implement Area and Perimeter Methods

This lesson discusses how to calculate the area and perimeter of a rectangle.

We'll cover the following


The area() and perimeter() methods are written in lines 17-21. They simply take the values of width() and height() and perform the following calculations on them:

Area=widthheightArea = width*height

Perimeter=2width+2heightPerimeter = 2*width + 2*height

This is shown in the code below:

Get hands-on with 1000+ tech skills courses.