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...
Solution:
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:
This is shown in the code below:
Access this course and 1400+ top-rated courses and projects.