Advertisement
Guest User

point

a guest
Sep 30th, 2014
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. package lektion05;
  2. //********************************************************************
  3. //Point.java Author: s144852
  4. //
  5. //Represents a point (x,y)
  6. //********************************************************************
  7.  
  8.  
  9. public class Point {
  10. int x, y;
  11.  
  12. // Sets up point with specified data
  13. Point(int xIn, int yIn) {
  14. x = xIn;
  15. y = yIn;
  16. }
  17.  
  18. // Returns true if the points are equal
  19. public boolean equals(Point p) {
  20. if (x == p.x && y == p.y) {
  21. return true;
  22. }
  23. else {
  24. return false;
  25. }
  26. }
  27.  
  28. // Moves the point by dx and dy
  29. public void move(int dx, int dy) {
  30. x += dx;
  31. y += dy;
  32. }
  33.  
  34. // Returns (x,y) in a string
  35. public String toString() {
  36. return ("(" + x + "," + y + ")");
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement