public  class Polygon extends Shape {
    
    private int numSides;
    private double sideLength;
    
    public Polygon(int numSides, double sideLength) {
        this.numSides = numSides;
        this.sideLength = sideLength;
        System.out.println("polygon created");
    }
    
    public Polygon(int numSides, double sideLength, double x, double y) {
        super(x,y);
        this.numSides = numSides;
        this.sideLength = sideLength;
        System.out.println("polygon created at given position");
    }

    public double getArea() {
        double theta = 2 * Math.PI / this.numSides;
        double r = this.sideLength / (2 * Math.sin(theta));
        return this.numSides * r * r * Math.sin(theta) * Math.cos(theta);
    }

    public double getPerimeter() {
        return this.numSides * this.sideLength;
    }
    
    public double getSideLength() {
        return this.sideLength;
    }
    
    public String toString() {
        return "polygon " + super.toString();
    }
    
    public void printWhoAmI() {
        System.out.println("I am a polygon!");
    }

}
