Created by joannazhang13
over 9 years ago
|
||
public class Rectangle extends Square{private double length;private double width;//constructorpublic Rectangle (double l, double w, String name){super(name);length=l;width= w;}public double getLength(){return length;}public double getWidth(){return width;}public double perimeter(){return (length+width)*2;}public double area(){return length*width;}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;}elsereturn -2;} }
Want to create your own Notes for free with GoConqr? Learn more.