-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathMovableCircle.java
More file actions
33 lines (25 loc) · 785 Bytes
/
MovableCircle.java
File metadata and controls
33 lines (25 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package src.ex5;
public class MovableCircle implements Movable {
private MovablePoint center;
private int radius;
public MovableCircle(int x, int y, int xSpeed, int ySpeed, int radius) {
center = new MovablePoint(x, y, xSpeed, ySpeed);
this.radius = radius;
}
public void moveUp() {
center.y -= center.ySpeed;
}
public void moveDown() {
center.y += center.ySpeed;
}
public void moveLeft() {
center.x -= center.xSpeed;
}
public void moveRight() {
center.x += center.xSpeed;
}
public String toString() {
return String.format("MovableCircle at point %1$s with radius = %2$d"
, center.toString(), radius);
}
}