1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19public
20class Nat1
21 extends AbstractOrdering
22{
23
24
25
26 protected
27 long n;
28
29
30
31
32 public
33 Nat1() {
34 n = 1;
35 }
36
37 public
38 Nat1(long n) {
39 assert n >= 1 : "argument <= 0";
40 this.n = n;
41 }
42
43 public
44 Nat1(int n) {
45 this((long)n);
46 }
47
48
49
50
51 public
52 int intValue() {
53 return
54 (int)n;
55 }
56
57 public
58 long longValue() {
59 return n;
60 }
61
62
63
64
65
66 protected
67 void assertNat1(Object o2) {
68 assert (o2 instanceof Nat1) : "not a Nat1 object";
69 }
70
71
72
73
74
75
76 public
77 boolean eq(Object o2)
78 {
79 assertNat1(o2);
80 return n == ((Nat1)o2).n;
81 }
82
83 public
84 boolean ge(Object o2)
85 {
86 assertNat1(o2);
87 return n >= ((Nat1)o2).n;
88 }
89}
90
91