Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MovableCircle implements Movable{
- private int radius;
- private MovablePoint centre;
- public MovableCircle(int x, int y, int xSpeed, int ySpeed, int radius){
- this.radius = radius;
- this.centre = new MovablePoint(x, y, xSpeed, ySpeed);
- }
- public String toString(){
- return "(" + centre.x + "," + centre.y + ")" + ", radius=" + this.radius;
- }
- public void moveUp(){
- centre.y -= centre.ySpeed;
- }
- public void moveDown(){
- centre.y += centre.ySpeed;
- }
- public void moveLeft(){
- centre.x -= centre.xSpeed;
- }
- public void moveRight(){
- centre.x += centre.xSpeed;
- }
- }
- class MovablePoint implements Movable{
- int x;
- int y;
- int xSpeed;
- int ySpeed;
- public MovablePoint(int x, int y, int xSpeed, int ySpeed){
- this.x = x;
- this.y = y;
- this.xSpeed = xSpeed;
- this.ySpeed = ySpeed;
- }
- public void moveUp(){
- y -= ySpeed;
- }
- public void moveDown(){
- y += ySpeed;
- }
- public void moveLeft(){
- x -= xSpeed;
- }
- public void moveRight(){
- x += xSpeed;
- }
- public String toString(){
- return "(" + x + "," + y + ")";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement