mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 09:40:21 +00:00
20 lines
338 B
Dart
20 lines
338 B
Dart
import 'dart:math' as math;
|
|
|
|
class Point {
|
|
num x, y;
|
|
|
|
Point(this.x, this.y);
|
|
|
|
num distanceTo(Point other) {
|
|
var dx = x - other.x;
|
|
var dy = y - other.y;
|
|
return math.sqrt(dx * dx + dy * dy);
|
|
}
|
|
}
|
|
|
|
void main() {
|
|
var p = new Point(2, 3);
|
|
var q = new Point(3, 4);
|
|
print('distance from p to q = ${p.distanceTo(q)}');
|
|
}
|