Advertisement
Guest User

Untitled

a guest
Aug 28th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. class MovableCircle implements Movable{
  2. private int radius;
  3. private MovablePoint centre;
  4.  
  5. public MovableCircle(int x, int y, int xSpeed, int ySpeed, int radius){
  6. this.radius = radius;
  7. this.centre = new MovablePoint(x, y, xSpeed, ySpeed);
  8. }
  9. public String toString(){
  10. return "(" + centre.x + "," + centre.y + ")" + ", radius=" + this.radius;
  11. }
  12. public void moveUp(){
  13. centre.y -= centre.ySpeed;
  14. }
  15. public void moveDown(){
  16. centre.y += centre.ySpeed;
  17. }
  18. public void moveLeft(){
  19. centre.x -= centre.xSpeed;
  20. }
  21. public void moveRight(){
  22. centre.x += centre.xSpeed;
  23. }
  24. }
  25.  
  26. class MovablePoint implements Movable{
  27. int x;
  28. int y;
  29. int xSpeed;
  30. int ySpeed;
  31.  
  32. public MovablePoint(int x, int y, int xSpeed, int ySpeed){
  33. this.x = x;
  34. this.y = y;
  35. this.xSpeed = xSpeed;
  36. this.ySpeed = ySpeed;
  37. }
  38. public void moveUp(){
  39. y -= ySpeed;
  40. }
  41. public void moveDown(){
  42. y += ySpeed;
  43. }
  44. public void moveLeft(){
  45. x -= xSpeed;
  46. }
  47. public void moveRight(){
  48. x += xSpeed;
  49. }
  50. public String toString(){
  51. return "(" + x + "," + y + ")";
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement