/home/caleb/ASDV-Java/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/Circle.java |
nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt
nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java
package com.calebfontenot.mp5_calebfontenot;
public class Circle extends GeometricObject {
private double diameter;
public Circle(double diameter) {
this.diameter = diameter;
System.out.println("Circle Diameter: " + diameter);
}
@Override
public double getArea() {
double radius = diameter / 2;
return Math.PI * Math.pow(radius, 2);
}
@Override
public double getPerimeter() {
return Math.PI * diameter;
}
@Override
public String toString() {
return "Circle{" + "diameter=" + diameter + '}';
}
@Override
public int compareTo(Object t) {
System.out.println(this.getArea() + ", " + ((Circle) t).getArea());
if (this.getArea() < ((Circle) t).getArea()) {
return -1;
} else if (this.getArea() > ((Circle) t).getArea()) {
return 1;
} else {
return 0;
}
}
@Override
public int compareTo() {
throw new UnsupportedOperationException("No compare object supplied!");
}
}