Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- public class Point {
- private int x;
- private int y;
- public Point() {
- }
- public int getX() {
- return x;
- }
- public void setX(int x) {
- this.x = x;
- }
- public int getY() {
- return y;
- }
- public void setY(int y) {
- this.y = y;
- }
- public Point(int x, int y) {
- this.x=x;
- this.y=y;
- }
- public double distance() {
- return Math.sqrt(Math.pow(x,2)+Math.pow(y,2));
- }
- public double distance(int x, int y) {
- return Math.sqrt(Math.pow(x-this.x, 2) + Math.pow(y-this.y, 2));
- }
- public double distance(Point p) {
- return distance(p.x, p.y);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement