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