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