Answered step by step
Verified Expert Solution
Question
1 Approved Answer
JAVA Create the following inheritance Hierarchy and add to it: Inheritance hierarchy UML class diagram for shape s. Your hierarchy should have a class Shape
JAVA
Create the following inheritance Hierarchy and add to it: Inheritance hierarchy UML class diagram for shape s. Your hierarchy should have a class Shape at the top. Classes TwoDimensionalShape and ThreeDimensionalShape should extend Shape. Add additional subclasses, such as and Sphere, at their correct locations in the hierarchy as necessary. Each class in this hierarchy should have a name field. Each class in this hierarchy should have a 0 argument constructor and one appropriate for the shape that sets the fields to passed take advantage of code reuse where posible. TwoDimensionalShape should have an abstract method area() that returns the area of a TwoDimensionalShape. ThreeDimensionalShape should have an abstract method volume that returns the volume of a ThreeDimensionalShape. Some of the classes in your hierarchy should be abstract. Use your best judgement as to which ones should be abstract and state in the comments of your code why certain classes are abstract. Your classes should implement the Comparable interface and have appropriate compareTo methods defined. Use your best judgement as to how to implement these mollowing the knowledge gleaned from your course materials. ThreeDimensionalShape to the hierarchy. These classes should have fields, get/set methods and multi-argument and 0 argument constructors appropriate to the shapes they are modeling. (EX: Circle should likely have a radius field and get/set methods for that field). Their area/volume methods should be the correct formulas for the particular shape. Use the following website to look up these formul needed or find the formulas on the internet if this page does not have them: https://www.skillsyouneed.comum/area-volume-reference.html In a class called ShapeTest with a main method create two instances of each class you created that inherits from TwoDimensionalShape or ThreeDimensionalShape. Add all of them to an ArrayList of Shapes. Add the objects that inherit from TwoDimensionalShape to an ArrayList of TwoDimensionalShapes and the objects that inherit from ThreeDimensionalShape to an ArrayList of ThreeDimensionalObjects. Demonstrate that your compareTwo methods work inside your main as well using the two unique objects of each type you createdStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started