Changeset 8edd04e in lost-haven for main/Point.java
- Timestamp:
- Jun 7, 2020, 3:04:32 PM (4 years ago)
- Branches:
- master
- Children:
- a49176d
- Parents:
- 155577b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/Point.java
r155577b r8edd04e 2 2 3 3 public 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 4 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 } 5 private int x; 6 private int xMin; 7 private int y; 8 private int yMin; 27 9 28 public int getX() { 29 return x; 30 } 31 32 public int getXMin() { 33 return xMin; 34 } 10 public Point() { 11 this.x = 0; 12 this.y = 0; 13 } 35 14 36 public int getY() { 37 return y; 38 } 39 40 public int getYMin() { 41 return yMin; 42 } 15 public Point(int x, int y) { 16 this.x = x; 17 this.xMin = 0; 18 this.y = y; 19 this.yMin = 0; 20 } 43 21 44 public void setX(int x) { 45 this.x = x; 46 } 47 48 public void setXMin(int xMin) { 49 this.xMin = xMin; 50 } 22 public Point(int x, int xMin, int y, int yMin) { 23 this.x = x; 24 this.xMin = xMin; 25 this.y = y; 26 this.yMin = yMin; 27 } 51 28 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 } 29 public Point(Point p) { 30 this.x = p.x; 31 this.xMin = p.xMin; 32 this.y = p.y; 33 this.yMin = p.yMin; 34 } 35 36 public int getX() { 37 return this.x; 38 } 39 40 public int getXMin() { 41 return this.xMin; 42 } 43 44 public int getY() { 45 return this.y; 46 } 47 48 public int getYMin() { 49 return this.yMin; 50 } 51 52 public void setX(int x) { 53 this.x = x; 54 } 55 56 public void setXMin(int xMin) { 57 this.xMin = xMin; 58 } 59 60 public void setY(int y) { 61 this.y = y; 62 } 63 64 public void setYMin(int yMin) { 65 this.yMin = yMin; 66 } 67 68 public boolean equals(Point p) { 69 return (this.x == p.x && this.y == p.y && this.xMin == p.xMin && this.yMin == p.yMin); 70 } 71 72 public String toString() { 73 return String.valueOf(this.x) + "," + this.y; 74 } 75 76 public static int xDif(Point p1, Point p2) { 77 return 100 * (p2.x - p1.x) + p2.xMin - p1.xMin; 78 } 79 80 public static int yDif(Point p1, Point p2) { 81 return 100 * (p2.y - p1.y) + p2.yMin - p1.yMin; 82 } 83 84 public static double dist(Point p1, Point p2) { 85 return Math.sqrt(Math.pow((p1.x + p1.xMin / 100 - p2.x - p2.xMin / 100), 2.0D) + Math.pow((p1.y + p1.yMin / 100 - p2.y - p2.yMin / 100), 2.0D)); 86 } 75 87 }
Note:
See TracChangeset
for help on using the changeset viewer.