Question
Expand the GeometricObject. This task has the following elements that are relevant to the learning outcomes of this module: - be able to create and
Expand the GeometricObject.
This task has the following elements that are relevant to the learning outcomes of this module:
- be able to create and use abstract classes - be able to use the classes Calendar and GregorianCalendar - be able to define common behavior for objects using interface - be able to define interfaces and classes that implement these - could use the Comparable interface
You should use the GeometricObject class that we have developed in the previous module. You should now further develop this by using interface and developing classes Triangle, Circle and Rectangle.
The program must:
- GeometricObject classes:
- It should be an abstract class so that it cannot be instituted.
- It must implement the Comparable interface and the associated int compareTo () method. Comparable is the interface defined in the Java library, you should not write your own Comparable interface. Area is used for comparison of geometric objects, the object with the largest area is assumed to be greatest by comparison.
- It should define three abstract methods, boolean equals (Object other), double getArea () and double getPerimeter (). These must be implemented by the children's classes.
- The class must have a static GeometricObject max (GeometricObject obj1, GeometricObject obj2) method that returns the largest object. Tip: Use the compareTo method when comparing obj1 and obj2
- Test class:
- It should create two objects of each class of different sizes.
- It should use the max method in GeometricObject to find the largest object of each type and print info about each.
- It should find the largest object of the three largest objects found at the point above.
- For the GeometricObject, Triangle, Rectangle and Circle classes see attached UML diagrams.
- Example of the application's print is:
The biggest circle: Circle Radius: 3.00 Created on: 2018-01-28 18:48:23 Color: white Is filled: no The biggest rectangle: Rectangle Width: 4.00 Height: 6.000000 Created on: 2018-01-28 18:48 : 23 Color: white Is filled: no The biggest triangle: Triangle Sides: 9.00, 10.00, 9.00 Created on: 2018-01-28 18:48:23 Color: white Is filled: no The biggest geometric object is: Triangle Sides: 9.00, 10.00, 9.00 Created on: 2018-01-28 18:48:23 Color: white Is filled: no
- UML Chart for Class:
Step 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