InasAwad

Untitled

Sep 18th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1. public class Point {
  2.  
  3.     private int x;
  4.     private int y;
  5.  
  6.     public Point() {
  7.     }
  8.  
  9.     public Point(int x, int y) {
  10.         this.x = x;
  11.         this.y = y;
  12.     }
  13.  
  14.     public int getX() {
  15.         return x;
  16.     }
  17.  
  18.     public void setX(int x) {
  19.         this.x = x;
  20.     }
  21.  
  22.     public int getY() {
  23.         return y;
  24.     }
  25.  
  26.     public void setY(int y) {
  27.         this.y = y;
  28.     }
  29.  
  30.     public double distance (Point m){
  31.      return distance(m.getY(), m.getY());
  32.     }
  33.     public double distance ( int a , int b){
  34.         return (Math.sqrt((this.x - b) * ( this.x-a) + (this.y -b) * (this.y - b)));
  35.     }
  36.     public double distance (){
  37.         return distance(0,0);
  38.     }
  39. }
Add Comment
Please, Sign In to add comment