Labsheet 7
Labsheet 7
Class Circle:
• Create a class Circle that extends Shape. Include:
Instance Variables:
double radius - to store the radius of the circle.
• Constructor:
A constructor to initialize the name and radius.
• Methods:
Implement the calculateArea() method to return the area of the circle (π * radius
* radius).
Class Rectangle:
• Create a class Rectangle that extends Shape. Include:
Instance Variables:
double length - to store the length of the rectangle.
double width - to store the width of the rectangle.
• Constructor:
A constructor to initialize the name, length, and width.
• Methods:
Implement the calculateArea() method to return the area of the rectangle (length
* width).