Advertisement
Guest User

Untitled

a guest
Oct 20th, 2014
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.62 KB | None | 0 0
  1. public class Point
  2. {
  3.     private double x;
  4.     private double y;
  5.  
  6.     public Point(double xValue, double yValue)
  7.     {
  8.         x = xValue;
  9.         y = yValue;
  10.     }
  11.  
  12.     public Point(Point p) {
  13.         this(p.x, p.y);
  14.     }
  15.  
  16.     public Point() {
  17.         this(0, 0);
  18.     }
  19.  
  20.     public void setX(double xValue)
  21.     {
  22.         x = xValue;
  23.     }
  24.  
  25.     public double getX()
  26.     {
  27.         return x;
  28.     }
  29.  
  30.     public void setY(double xValue)
  31.     {
  32.         y = xValue;
  33.     }
  34.  
  35.     public double getY()
  36.     {
  37.         return y;
  38.     }
  39.  
  40.     public boolean equals(Point otherPoint)
  41.     {
  42.         return (this.x == otherPoint.x) && (this.y == otherPoint.y);
  43.     }
  44.  
  45.     public String toString() {
  46.         return "(" + x + ", " + y + ")";
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement