abstract class FormaGeometrica {
    abstract calcularArea(): number;
}

class Quadrado extends FormaGeometrica {
    constructor(private lado: number) {
        super();
    }

    calcularArea(): number {
        return this.lado * this.lado;
    }
}

class Circulo extends FormaGeometrica {
    constructor(private raio: number) {
        super();
    }

    calcularArea(): number {
        return Math.PI * this.raio * this.raio;
    }
}

const formas: FormaGeometrica[] = [
    new Quadrado(5),
    new Circulo(3)
];

formas.forEach(forma => {
    console.log(`Área: ${forma.calcularArea().toFixed(2)}`);
});

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: