1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19public
20class Nat0
21 implements Ordering
22{
23
24
25
26 protected
27 long n;
28
29
30
31
32 public
33 Nat0() {
34 n = 0;
35 }
36
37 public
38 Nat0(long n) {
39 assert n >= 0 : "negative argument";
40
41 this.n = n;
42 }
43
44 public
45 Nat0(int n) {
46 this((long)n);
47 }
48
49
50
51
52 public
53 int intValue() {
54 return
55 (int)n;
56 }
57
58 public
59 long longValue() {
60 return n;
61 }
62
63
64
65
66
67 protected
68 void assertNat0(Object o2) {
69 assert (o2 instanceof Nat0) : "not a Nat0 object";
70 }
71
72
73
74
75
76
77 public
78 boolean eq(Object o2)
79 {
80 assertNat0(o2);
81 return n == ((Nat0)o2).n;
82 }
83
84 public
85 boolean ge(Object o2)
86 {
87 assertNat0(o2);
88 return n >= ((Nat0)o2).n;
89 }
90
91 public
92 boolean gr(Object o2)
93 {
94 assertNat0(o2);
95 return n > ((Nat0)o2).n;
96 }
97
98 public
99 boolean ne(Object o2) {
100 return ! eq(o2);
101 }
102
103 public
104 boolean le(Object o2) {
105 return ! gr(o2);
106 }
107
108 public
109 boolean lt(Object o2) {
110 return ! ge(o2);
111 }
112}
113
114