Files
linguist/samples/Dart/point.dart
2013-12-30 16:39:25 -08:00

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)}');
}