Advertisement
Guest User

Untitled

a guest
Jan 26th, 2015
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. public class point
  2. {
  3. private int x;
  4. private int y;
  5. private double a;
  6. private double b;
  7.  
  8. //constructs a new point with (0,0) as coordinates
  9. public point()
  10. {
  11. x=0;
  12. y=0;
  13. }
  14.  
  15. //constructs a new point with the given (x,y) location
  16. public point(int initialX, int initialY)
  17. {
  18. x = initialX;
  19. y = initialY;
  20. }
  21.  
  22. //constructs a new point with coordinates of type double
  23. public point(double initialX, double initialY)
  24. {
  25.  
  26. if((initialX-(int) initialX)>0.5)
  27. a=(int)initialX + 1;
  28.  
  29. if((initialY-(int) initialY)>0.5)
  30. b=(int)initialY + 1;
  31.  
  32. }
  33.  
  34. //returns the x-coordinate of this point
  35. int getX()
  36. {
  37. return x;
  38. }
  39.  
  40. //returns the y-coordinate of this point
  41. public int getY()
  42. {
  43. return y;
  44. }
  45.  
  46. public String toString()
  47. {
  48.  
  49. return("(" + x + ", " + y + ")");
  50. }
  51.  
  52.  
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement