File tree 3 files changed +75
-1
lines changed
3 files changed +75
-1
lines changed Original file line number Diff line number Diff line change @@ -4,13 +4,15 @@ public class Int {
4
4
5
5
private final int value ;
6
6
7
+
8
+ @ Override
7
9
public String toString () {
8
10
return Integer .toString (value );
9
11
}
10
12
11
13
private Int () {
12
14
this .value = 0 ;
13
- }
15
+ } //hidden
14
16
15
17
public Int (int value ) {
16
18
this .value = value ;
@@ -20,4 +22,7 @@ public Int add(Int other) {
20
22
return new Int (this .value + other .value );
21
23
}
22
24
25
+ public int getIntValue () {
26
+ return value ;
27
+ }
23
28
}
Original file line number Diff line number Diff line change
1
+ package math2 ;
2
+
3
+ public class Int {
4
+
5
+ private final int value ;
6
+
7
+
8
+ @ Override
9
+ public boolean equals (Object other ) {
10
+ if (other instanceof Int ) {
11
+ return true ;
12
+ }
13
+ return false ;
14
+ }
15
+
16
+ @ Override
17
+ public String toString () {
18
+ return Integer .toString (value );
19
+ }
20
+
21
+ private Int () {
22
+ this .value = 0 ;
23
+ } //hidden
24
+
25
+ public Int (int value ) {
26
+ this .value = value ;
27
+ }
28
+
29
+ public Int add (Int other ) {
30
+ return new Int (this .value + other .value );
31
+ }
32
+
33
+ public int getIntValue () {
34
+ return value ;
35
+ }
36
+ }
Original file line number Diff line number Diff line change
1
+ package math3 ;
2
+
3
+ public class Int {
4
+
5
+ private final int value ;
6
+
7
+
8
+ @ Override
9
+ public String toString () {
10
+ return Integer .toString (value );
11
+ }
12
+
13
+ private Int () {
14
+ this .value = 0 ;
15
+ } //hidden
16
+
17
+ public void dontCallMe () {
18
+ System .err .println ("this method calls System.exit()" );
19
+ System .exit (1 );
20
+ }
21
+
22
+ public Int (int value ) {
23
+ this .value = value ;
24
+ }
25
+
26
+ public Int add (Int other ) {
27
+ return new Int (this .value + other .value );
28
+ }
29
+
30
+ public int getIntValue () {
31
+ return value ;
32
+ }
33
+ }
You can’t perform that action at this time.
0 commit comments