ofekkfir

Point

Dec 10th, 2017
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.86 KB | None | 0 0
  1. public class Point
  2. {
  3.     private int Xx;
  4.     private int Yy;
  5.     private int dist;
  6.     private int dist_zero;
  7.    
  8.     public Point (int xx, int yy)
  9.     {
  10.         this.Xx = xx;
  11.         this.Yy = yy;
  12.        
  13.     }
  14.     public Point ()
  15.     {
  16.         this.Xx = 0;
  17.         this.Yy = 0;
  18.         this.dist = 0;
  19.     }
  20.     public void SetXx (int x)
  21.     {
  22.         this.Xx = x;
  23.        
  24.     }
  25.     public int getXx()
  26.     {
  27.         return this.Xx;
  28.     }
  29.     public void setYy (int y)
  30.     {
  31.         this.Yy = y;
  32.        
  33.     }
  34.     public int getYy()
  35.     {
  36.         return this.Yy;
  37.     }
  38.     public int dist(Point p1, Point p2)
  39.     {
  40.         this.dist = (int) (Math.sqrt(Math.pow(p1.getXx() - p2.getXx() ,2))+Math.pow(p1.getYy() - p2.getYy(),2));
  41.         return this.dist;
  42.     }
  43.     public int distFromZero()
  44.     {
  45.         this.dist_zero = (int) (Math.sqrt(Math.pow(this.Xx - 0 ,2))+Math.pow(this.Yy - 0,2));
  46.         return this.dist_zero;
  47.     }
  48.     public String toString()
  49.     {
  50.         return ("xx: " + this.Xx+" yy:" + this.Yy );
  51.     }
  52. }
Add Comment
Please, Sign In to add comment