package inheritance;

public class Rectangle extends Shape {
    
    private double length;
    private double width;
    
    Rectangle(double length, double width){
        this.length = length;
        this.width = width;
    }
    
    @Override
    public double area() {
        return getLength()*getWidth();
    }

    @Override
    public double perimeter() {
        return 2*(getLength()+getWidth());
    }

    public double getLength() {
        return length;
    }

    public void setLength(double length) {
        this.length = length;
    }

    public double getWidth() {
        return width;
    }

    public void setWidth(double width) {
        this.width = width;
    }
    
    public String toString(){
        return "Rectangle: "+length+" x "+width+"\nPerimeter: "+perimeter()+"\nArea: "+area();
    }
    
    public static void main(String[] args) {
        Shape r1 = new Rectangle(5,10);
        Shape r2 = new Rectangle(2,25);
        Shape r3 = new Rectangle(1,10);
        
        System.out.println("\n[r1]");
        System.out.println(r1);
        System.out.println("\n[r2]");
        System.out.println(r2);
        System.out.println("\n[r3]");
        System.out.println(r3);
        //System.out.println("Area2: "+r1.area2());
        
        
        
        System.out.println("\ncompareTo\n-----------------------------------------------------------");
        //System.out.print(r.compareTo(r2));
        System.out.println("r1 compared to r2:\t" + r1.compareTo(r2));
        System.out.println("r1 compared to r3:\t" + r1.compareTo(r3));
        System.out.println("r2 compared to r3:\t" + r2.compareTo(r3));
    }
    
}
