25 public __ByValue final class Point {
26 final int x;
27 final int y;
28
29 private Point() {
30 x = 0;
31 y = 0;
32 }
33
34 public int getX() { return x; }
35 public int getY() { return y; }
36
37 public boolean isSamePoint(Point that) {
38 return this.getX() == that.getX() && this.getY() == that.getY();
39 }
40
41 public String toString() {
42 return "Point: x=" + getX() + " y=" + getY();
43 }
44
45 __ValueFactory public static Point createPoint(int x, int y) {
46 Point p = __MakeDefault Point();
47 p.x =x;
48 p.y = y;
49 return p;
50 }
51 }
|
25 public __ByValue final class Point {
26 final int x;
27 final int y;
28
29 private Point() {
30 x = 0;
31 y = 0;
32 }
33
34 public int getX() { return x; }
35 public int getY() { return y; }
36
37 public boolean isSamePoint(Point that) {
38 return this.getX() == that.getX() && this.getY() == that.getY();
39 }
40
41 public String toString() {
42 return "Point: x=" + getX() + " y=" + getY();
43 }
44
45 public boolean equals(Object o) {
46 if(o instanceof Point) {
47 return ((Point)o).x == x && ((Point)o).y == y;
48 } else {
49 return false;
50 }
51 }
52
53 public static Point createPoint(int x, int y) {
54 Point p = __MakeDefault Point();
55 p.x =x;
56 p.y = y;
57 return p;
58 }
59 }
|