source: lost-haven/main/Point.java@ 155577b

Last change on this file since 155577b was 0870468, checked in by Dmitry Portnoy <dmitry.portnoy@…>, 4 years ago

Move all global classes into the main package

  • Property mode set to 100644
File size: 1.2 KB
Line 
1package main;
2
3public class Point {
4 private int x;
5 private int xMin;
6 private int y;
7 private int yMin;
8
9 public Point() {
10 x = 0;
11 y = 0;
12 }
13
14 public Point(int x, int y) {
15 this.x = x;
16 this.xMin = 0;
17 this.y = y;
18 this.yMin = 0;
19 }
20
21 public Point(int x, int xMin, int y, int yMin) {
22 this.x = x;
23 this.xMin = xMin;
24 this.y = y;
25 this.yMin = yMin;
26 }
27
28 public int getX() {
29 return x;
30 }
31
32 public int getXMin() {
33 return xMin;
34 }
35
36 public int getY() {
37 return y;
38 }
39
40 public int getYMin() {
41 return yMin;
42 }
43
44 public void setX(int x) {
45 this.x = x;
46 }
47
48 public void setXMin(int xMin) {
49 this.xMin = xMin;
50 }
51
52 public void setY(int y) {
53 this.y = y;
54 }
55
56 public void setYMin(int yMin) {
57 this.yMin = yMin;
58 }
59
60 public String toString() {
61 return x+","+y;
62 }
63
64 public static int xDif(Point p1, Point p2) {
65 return 100*(p2.x-p1.x)+p2.xMin-p1.xMin;
66 }
67
68 public static int yDif(Point p1, Point p2) {
69 return 100*(p2.y-p1.y)+p2.yMin-p1.yMin;
70 }
71
72 public static double dist(Point p1, Point p2) {
73 return Math.sqrt(Math.pow(p1.x+p1.xMin/100-p2.x-p2.xMin/100, 2)+Math.pow(p1.y+p1.yMin/100-p2.y-p2.yMin/100, 2));
74 }
75}
Note: See TracBrowser for help on using the repository browser.