Created by joannazhang13
over 9 years ago
|
||
public class Circle extends Shape{ private double radius; //constructor public Circle (double r, String name) { super(name); radius= r; } public double getRadius() { return radius; } public double perimeter() { return 2*Math.PI*radius; } public double area() { return Math.PI*Math.pow(radius, 2); } public int compareTo(Shape s) { if (s.getName()==name { if(s.getRadius()==radius) return 0; else if(s.getRadius()> radius) return -1; else return 1; } else return -2; } }
Want to create your own Notes for free with GoConqr? Learn more.