File tree Expand file tree Collapse file tree 3 files changed +75
-1
lines changed Expand file tree Collapse file tree 3 files changed +75
-1
lines changed Original file line number Diff line number Diff line change @@ -4,13 +4,15 @@ public class Int {
44
55 private final int value ;
66
7+
8+ @ Override
79 public String toString () {
810 return Integer .toString (value );
911 }
1012
1113 private Int () {
1214 this .value = 0 ;
13- }
15+ } //hidden
1416
1517 public Int (int value ) {
1618 this .value = value ;
@@ -20,4 +22,7 @@ public Int add(Int other) {
2022 return new Int (this .value + other .value );
2123 }
2224
25+ public int getIntValue () {
26+ return value ;
27+ }
2328}
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