blob: 102a08773f2df92844f2aa86736d415563aa8166 [file] [log] [blame]
import 'dart:math' as math;
sealed class Shape {
double calculateArea();
}
class Square implements Shape {
final double length;
Square(this.length);
double calculateArea() => length * length;
}
class Circle implements Shape {
final double radius;
Circle(this.radius);
double calculateArea() => math.pi * radius * radius;
}
double calculateArea(Shape shape) => switch (shape) {
Square(length: var l) => l * l,
Circle(radius: var r) => math.pi * r * r
};
main() {}
expect(expected, actual) {}