Question: Define the following class hierarchy for shapes: (a) Define an abstract class Shape. Shapes have a color (which can be a string for now) and

 Define the following class hierarchy for shapes: (a) Define an abstract

Define the following class hierarchy for shapes: (a) Define an abstract class Shape. Shapes have a color (which can be a string for now) and a boolean indicating whether or not they are filled. These should be properly encapsulated. (b) Define an abstract class Shape2D that extends Shape. This class should define the abstract method getArea ) that returns the area of a a Shape2D (c) Define a class Rectangle that extends Shape2D. A rectangle has a height and a width. Implement the getArea () method appropriately. Use the @Override annotation. (d) Define a class Square that extends Rectangle. The class should have an ap propriate constructor and also override setter methods as approrpiate to preserve 13 "squareness." (e) Define a class Ellipse that extends Shape2D. An ellipse has a semi-major axis a and a semi-minor axis b (look it up if needed). The area of an ellipse is A ab. (f) Define a class Circle that extends Ellipse. You need appropriate contruc- tor(s) and setter(s) for the class. Ilustrate all of these with a main method in a separate test class

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!