Circle - { Circle rect = (Circle)o; if (calculateArea()

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
class Circle extends GraphicObject implements Comparable { private double radius; public Circle(String color, double radius) { super(color); this.radius = radius; } public double getRadius() { return radius; } public void setRadius(double radius) { this.radius = radius; } public double calculateArea() { double area = 0; area = Math.PI*(getRadius()*getRadius()); return area; } public double calculatePerimeter() { return 2*(Math.PI+radius); } public int compareTo(Object o) { if (o instanceof Circle)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { Circle rect = (Circle)o; if (calculateArea() >rect.calculateArea()) { return -1; } if (calculateArea() ==rect.calculateArea()) { return 0; } if (calculateArea() <rect.calculateArea()) { return 1; } } return 100; } public boolean equals(Object o) { if (o instanceof Circle) { Circle circle = (Circle)o; if (getRadius()==(circle.getRadius())) { return true; } else return false; } else return false; } }...
View Full Document

Page1 / 2

Circle - { Circle rect = (Circle)o; if (calculateArea()

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online