Find Us On:

# seeker geo object

bthn

Modify the 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. Attachments Tags Clarifications

## Java - Geometric Object - Solution

dickersonka

Attached is the solution including source, comments, and output for the Java - Geometric Object assignment Attachments
GeometricObject.zip (2 K)
Preview
System.out.println("Circle Test"); //create two circles Circle circle1 = new Circle (6.6); Circle circle2 = new Circle (7.9); System.out.println("Circle 1 radius is: " + circle1.getRadius()); System.out.println("Circle 1 area is: " + circle1.getArea()); System.out.println("Circle 2 radius

Preview
* Get area */ public double getArea(){ return width * height; } /** * Get perimeter */ public double getPerimeter(){ return (width + height)*2; } /** * Set width * @param width width */

Preview
radius */ public Circle (double radius){ this.radius = radius; } /** * Get area */ public double getArea(){ return Math.PI * (radius * radius); } /** * Get perimeter */

Preview
Circle Test Circle 1 radius is: 6.6 Circle 1 area is: 136.84777599037136 Circle 2 radius is: 7.9 Circle

Preview
is isFilled*/ public boolean isFilled() { return filled; } /**Setter method for filled*/ public void setFilled(boolean filled) { this.filled = filled; } /**Abstract method findArea*/ public abstract double getArea(); /**Abstract method getPerimeter*/ public abstract double getPerimeter();

Screenshots