interface Shape {
  area(): number;
}

interface SolidShape {
  volume(): 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 Cube implements Shape, SolidShape {
  area(): number {
    return 0;
  }

  volume(): number {
    return 0;
  }
}

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

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

class VolumeCalculator extends AreaCalculator {
  constructor(private readonly solidShapes: SolidShape[]) {
    super([]);
  }

  public sum(): number {
    // logique de calcul, on retournerait la somme des volumes
    return this.solidShapes.reduce((total, shape) => total + shape.volume(), 0);
  }
}

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 Cube(),new Cube()]);
const outputter = new SumConsoleOutputter(calculator);

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

export default {};
