interface Shape {
  area(): number;
}

class Circle implements Shape {
  constructor(private readonly radius: number) {}

  area(): number {
    return Math.PI * Math.pow(this.radius, 2);
  }
}

class Square implements Shape {
  constructor(private readonly length: number) {}

  area(): number {
    return Math.pow(this.length, 2);
  }
}

class AreaCalculator {
  constructor(private readonly shapes: Shape[]) {}

  public sum(): number {
    return this.shapes.reduce((total, shape) => total + shape.area(), 0);
  }
}

class VolumeCalculator extends AreaCalculator {
  // @ts-ignore
  public sum(): number[] {
    // logique de calcul
    return [
      /** volume pour chaque forme */
    ];
  }
}

class SumConsoleOutputter {
  constructor(private readonly calculator: AreaCalculator) {}

  public output(): void {
    const sum = this.calculator.sum();
    console.log(`Somme des aires : ${sum}`);
  }
}

const calculator = new VolumeCalculator([new Circle(5), new Square(4)]);
// @ts-ignore
const outputter = new SumConsoleOutputter(calculator);

outputter.output(); // affiche la somme des aires

export default {};
