Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Point {
- public int x;
- public int y;
- public Point() {
- this.x = 0;
- this.y = 0;
- }
- public Point(int x, int y) {
- this.x = x;
- this.y = y;
- }
- /**
- * @return the x
- */
- public int getX() {
- return x;
- }
- /**
- * @param x the x to set
- */
- public void setX(int x) {
- this.x = x;
- }
- /**
- * @return the y
- */
- public int getY() {
- return y;
- }
- /**
- * @param y the y to set
- */
- public void setY(int y) {
- this.y = y;
- }
- public double distanceFormula(Point p1, Point p2) {
- double distance;
- distance = Math.sqrt( ( (p1.getX() - p2.getX()) * (p1.getX() - p2.getX() ) +
- (p1.getY() - p2.getY()) * (p1.getY() - p2.getY() )
- ) ) ;
- return distance;
- }
- public String toString() {
- return this.getClass().getName() + " is: ( " + this.getX() + ", " + this.getY() + " )";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement