Line data Source code
1 : class Distance implements Comparable<Distance> {
2 : /*
3 : * The value of this Distance object in meters.
4 : */
5 : final double _distance;
6 :
7 3 : const Distance({double meters : 0.0}) : _distance = meters;
8 :
9 : /**
10 : * Compares this Distance to [other], returning zero if the values are equal.
11 : *
12 : * Returns a negative integer if this `Distance` is shorter than
13 : * [other], or a positive integer if it is longer.
14 : *
15 : * A negative `Distance` is always considered shorter than a positive one.
16 : *
17 : */
18 3 : int compareTo(Distance other) => _distance.compareTo(other._distance);
19 :
20 1 : double get inMeters => _distance;
21 : }
|