blob: bb75ee5d21f68ff940b39d208aceb1f1c9f7d403 [file] [log] [blame]
import 'dart:math' show pi;
abstract class Shape {}
class Square implements Shape {
final double length;
Square(this.length);
}
class Circle implements Shape {
final double radius;
Circle(this.radius);
}
double calculateArea(Shape shape) => switch (shape) {
Square(length: var l) when l >= 0 => l * l,
Circle(radius: var r) when r >= 0 => pi * r * r,
Square(length: var l) when l < 0 => -1,
Circle(radius: var r) when r < 0 => -1,
Shape() => 0
};
testMain() {}