Rectangles and Circles

All the interesting stuff is in the JavaScript, so open up a JavaScript console and look at the console.log output.

class Circ {
    // constructor takes a center point {x,y} and a radius
    constructor(center, radius) {
        this.center = center;
        this.radius = radius;
    }

    area() {
        const r = this.radius;
        return Math.PI*r*r;
    }
}

// origin is defined in rect.js

var c1 = new Circ(origin, 10);
console.log(c1);
console.log("area of c1 is "+c1.area());

var objs = [ r1,
             c1,
             new Rect(p1, {x: 5, y: 15}),
             new Circ( p1, 100) ];

objs.forEach((obj, i) => { 
    console.log(i+" area of "+obj+" is "+obj.area());
});