Lab Tasks 8
Lab Tasks 8
Task 1
1. BasicShape interface:
Design an interface called BasicShape with the following members:
- `calcArea()`: A method that should be implemented by any class that implements this interface.
This method calculates the area of the shape.
- `display()`: A method that should be implemented by any class that implements this interface.
This method displays information about the shape.
2. Displayable interface:
Design an interface called Displayable with the following members:
- `displayWithPrecision(int precision)`: A method that should be implemented by any class that
implements this interface. This method displays information about the shape with the specified
precision.
4. Circle class:
Design a class called Circle, which extends the ShapeWithArea abstract class and implements the
BasicShape and Displayable interfaces, to represent a circle. The Circle class should have the
following members:
Private Member Variables:
- centerX: a long integer used to hold the x-coordinate of the circle's center.
- centerY: a long integer used to hold the y-coordinate of the circle's center.
- radius: a double used to hold the circle's radius.
5. Rectangle class:
Design a class called Rectangle, which extends the ShapeWithArea abstract class and implements
the BasicShape and Displayable interfaces, to represent a rectangle. The Rectangle class should
have the following members:
Private Member Variables:
- width: a long integer used to hold the width of the rectangle.
- length: a long integer used to hold the length of the rectangle.
6. A Driver Class:
Create a driver class with main method that instantiates objects of Circle and Rectangle classes.
Demonstrate that each object properly calculates and displays its area and additional information
with default precision and custom precision using the `display()` and `displayWithPrecision(int
precision)` methods from the BasicShape and Displayable interfaces, respectively.