Question: 2. (12 points) Solve the following problem (Ch. 9) (a) Write an abstract superclass encapsulating the concept of a shape. The superclass has two abstract

2. (12 points) Solve the following problem (Ch. 9) (a) Write an abstract superclass encapsulating the concept of a shape. The superclass has two abstract methods: one returning the perimeter of the shape, and another returning the area of the shape. It also has a constant field PI (t). This class has two non-abstract subclasses: one encapsulating a circle, and the other encapsulating a rectangle. A circle has one additional attribute, its radius. A rectangle has two additional attributes, its width and height. Include a constructor, getters, and toString methods. (b) The circle class has a subclass encapsulating a cylinder. A cylinder has a circle as its base, and another attribute, its length. It has two methods calculating and returning its area and volume Include a constructor, getters, and toString methods. (c) The rectangle class has a subclass encapsulating a parallelepiped, or box. A parallelepiped has a rectangle as its base, and another attribute for its length. It has two methods that calculate and return its area and volume. Include a constructor, getters, and toString methods (d) Write a client class to test all the classes
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
