Rev | Line | |
---|
[04e7260] | 1 |
|
---|
| 2 | public class Point {
|
---|
| 3 | private int x;
|
---|
| 4 | private int y;
|
---|
| 5 |
|
---|
| 6 | public Point() {
|
---|
| 7 | x = 0;
|
---|
| 8 | y = 0;
|
---|
| 9 | }
|
---|
| 10 |
|
---|
| 11 | public Point(int x, int y) {
|
---|
| 12 | this.x = x;
|
---|
| 13 | this.y = y;
|
---|
| 14 | }
|
---|
| 15 |
|
---|
| 16 | public int getX() {
|
---|
| 17 | return x;
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 | public int getY() {
|
---|
| 21 | return y;
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | public void setX(int x) {
|
---|
| 25 | this.x = x;
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | public void setY(int y) {
|
---|
| 29 | this.y = y;
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | public String toString() {
|
---|
| 33 | return x+","+y;
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | public static double dist(Point p1, Point p2) {
|
---|
| 37 | return Math.sqrt(Math.pow(p1.x-p2.x, 2)+Math.pow(p1.y-p2.y, 2));
|
---|
| 38 | }
|
---|
| 39 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.