Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Define class Point, to using in some of next tasks.
- public class Point {
- private double x, y;
- public double getX() {
- return x;
- }
- public void setX(double x) {
- this.x = x;
- }
- public double getY() {
- return y;
- }
- public void setY(double y) {
- this.y = y;
- }
- public Point(double x, double y) {
- // TODO Auto-generated constructor stub
- this.x = x;
- this.y = y;
- }
- public static double minusX(Point point1, Point point2) {
- return point1.x - point2.x;
- }
- public static double minusY(Point point1, Point point2) {
- return point1.y - point2.y;
- }
- public static double distanceBetween(Point point1, Point point2) {
- double deltaX = Point.minusX(point2, point1);
- double deltaY = Point.minusY(point2, point1);
- return Math.sqrt((deltaX * deltaX) + (deltaY * deltaY));
- }
- public static boolean equals(Point point1, Point point2) {
- return point1.x == point2.x && point1.y == point2.y;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement