Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Could you please help me on this JAVA program to find the largest of circle and

ID: 3597454 • Letter: C

Question

Could you please help me on this JAVA program to find the largest of circle and rectangle by modifying the following program? I really appreciate your help

Modify the blow GeometricObject class to implement the Comparable interface, and define a static max method in the GeometricObject class for finding the larger of two GeometricObject objects.

Write a test program that uses the max method to find the larger of two circles and the larger of two rectangles.

public class GeometricObject1 {

              private String color = "white";

              private boolean filled;

              private java.util.Date dateCreated;

             

              /** Construct a default geometric object */

              public GeometricObject1() {

                  dateCreated = new java.util.Date();

              }

              /** Construct a geometric object with the specified color

                  * and filled value */

              public GeometricObject1(String color, boolean filled) {

                  dateCreated = new java.util.Date();

                  this.color = color;

                  this.filled = filled;

              }

              /** Return color */

              public String getColor() {

                  return color;

              }

              /** Set a new color */

              public void setColor(String color) {

                  this.color = color;

              }

              /** Return filled. Since filled is boolean,

                   its get method is named isFilled */

              public boolean isFilled() {

                  return filled;

              }

              /** Set a new filled */

              public void setFilled(boolean filled) {

                  this.filled = filled;

              }

             

              /** Get dateCreated */

              public java.util.Date getDateCreated() {

                  return dateCreated;

              }

             

              /** Return a string representation of this object */

              public String toString() {

                  return "created on " + dateCreated + " color: " + color +

                    " and filled: " + filled;

              }

              }

       public class Circle1 extends GeometricObject1 {

              private double radius;

              public Circle1() {

              }

              public Circle1(double radius) {

                  this.radius = radius;

              }

              public Circle1(double radius, String color, boolean filled) {

                  this.radius = radius;

                  setColor(color);

                  setFilled(filled);

              }

              /** Return radius */

              public double getRadius() {

                  return radius;

              }

              /** Set a new radius */

              public void setRadius(double radius) {

                  this.radius = radius;

              }

              /** Return area */

              public double getArea() {

                  return radius * radius * Math.PI;

              }

             

              /** Return diameter */

              public double getDiameter() {

                  return 2 * radius;

              }

             

              /** Return perimeter */

              public double getPerimeter() {

                  return 2 * radius * Math.PI;

              }

              /* Print the circle info */

              public void printCircle() {

                  System.out.println("The circle is created " + getDateCreated() +

                    " and the radius is " + radius);

              }

              }

       public class Rectangle extends GeometricObject1 {

              private double width;

              private double height;

              public Rectangle() {

              }

              public Rectangle(double width, double height) {

                  this.width = width;

                  this.height = height;

              }

              public Rectangle(double width, double height, String color,

                    boolean filled) {

                  this.width = width;

                  this.height = height;

                  setColor(color);

                  setFilled(filled);

              }

              /** Return width */

              public double getWidth() {

                  return width;

              }

              /** Set a new width */

              public void setWidth(double width) {

                  this.width = width;

              }

              /** Return height */

              public double getHeight() {

                  return height;

              }

              /** Set a new height */

              public void setHeight(double height) {

                  this.height = height;

              }

              /** Return area */

              public double getArea() {

                  return width * height;

              }

              /** Return perimeter */

              public double getPerimeter() {

                  return 2 * (width + height);

              }

              }

Explanation / Answer

*********************************GeometricObject Class*************************************

*********************************************** Circle Class *********************************************************

*********************************** Rectangle Class ***********************************

******************************* Test Class ******************************

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote