]>
Commit | Line | Data |
---|---|---|
92b19250 | 1 | package de.cwde.freeshisen; |
c6f3dff3 | 2 | |
3 | class Point { | |
4 | public Point(int i, int j) { | |
109ae6fe | 5 | this.i = i; |
6 | this.j = j; | |
7 | } | |
8 | ||
9 | public Point(Point p) { | |
10 | this.i = p.i; | |
11 | this.j = p.j; | |
c6f3dff3 | 12 | } |
13 | ||
14 | public boolean equals(Point p) { | |
109ae6fe | 15 | return (i == p.i && j == p.j); |
16 | } | |
17 | ||
18 | public boolean equals(int myi, int myj) { | |
19 | return (i == myi && j == myj); | |
c6f3dff3 | 20 | } |
21 | ||
22 | public String toString() { | |
109ae6fe | 23 | return "(" + i + "," + j + ")"; |
24 | } | |
25 | ||
26 | public void set(int i, int j) { | |
27 | this.i = i; | |
28 | this.j = j; | |
c6f3dff3 | 29 | } |
30 | ||
31 | public static Point fromString(String s) { | |
109ae6fe | 32 | String[] ij = s.split(",", 2); |
33 | int i = Integer.parseInt(ij[0]); | |
34 | int j = Integer.parseInt(ij[1]); | |
35 | return new Point(i, j); | |
c6f3dff3 | 36 | } |
37 | ||
38 | public int i; | |
39 | public int j; | |
40 | ||
41 | public Point copy() { | |
109ae6fe | 42 | return new Point(this.i, this.j); |
c6f3dff3 | 43 | } |
44 | } |