-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMovableRectangle.java
More file actions
41 lines (37 loc) · 1.05 KB
/
Copy pathMovableRectangle.java
File metadata and controls
41 lines (37 loc) · 1.05 KB
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
34
35
36
37
38
39
40
41
package Movable;
public class MovableRectangle implements Movable {
private MovablePoint topLeft;
private MovablePoint bottomRight;
public MovableRectangle (int x1, int y1, int x2, int y2, int xSpeed,
int ySpeed) {
this.topLeft = new MovablePoint(x1, y1, xSpeed, ySpeed);
this.bottomRight = new MovablePoint(x2, y2, xSpeed, ySpeed);
}
@Override
public String toString() {
return "MovableRectangle{" +
"topLeft=" + topLeft +
", bottomRight=" + bottomRight +
'}';
}
@Override
public void moveUp() {
topLeft.moveUp();
bottomRight.moveUp();
}
@Override
public void moveDown() {
topLeft.moveDown();
bottomRight.moveDown();
}
@Override
public void moveRight() {
topLeft.moveRight();
bottomRight.moveRight();
}
@Override
public void moveLeft() {
topLeft.moveLeft();
bottomRight.moveLeft();
}
}