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