Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Point
- {
- private int Xx;
- private int Yy;
- private int dist;
- private int dist_zero;
- public Point (int xx, int yy)
- {
- this.Xx = xx;
- this.Yy = yy;
- }
- public Point ()
- {
- this.Xx = 0;
- this.Yy = 0;
- this.dist = 0;
- }
- public void SetXx (int x)
- {
- this.Xx = x;
- }
- public int getXx()
- {
- return this.Xx;
- }
- public void setYy (int y)
- {
- this.Yy = y;
- }
- public int getYy()
- {
- return this.Yy;
- }
- public int dist(Point p1, Point p2)
- {
- this.dist = (int) (Math.sqrt(Math.pow(p1.getXx() - p2.getXx() ,2))+Math.pow(p1.getYy() - p2.getYy(),2));
- return this.dist;
- }
- public int distFromZero()
- {
- this.dist_zero = (int) (Math.sqrt(Math.pow(this.Xx - 0 ,2))+Math.pow(this.Yy - 0,2));
- return this.dist_zero;
- }
- public String toString()
- {
- return ("xx: " + this.Xx+" yy:" + this.Yy );
- }
- }
Add Comment
Please, Sign In to add comment