-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathObstacleDecorator.java
47 lines (41 loc) · 1.05 KB
/
ObstacleDecorator.java
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
42
43
44
45
46
47
import java.awt.Graphics2D;
/**
* This class is superclass for the bump and hill obstacle. It implements the
* Movable interface.
*
* @author ChangSu Nam
* @UNI cn2521
* @since Assignment4 2.3
*/
public class ObstacleDecorator implements Movable {
/**
*
* Constructor that creates ObstacleDecorator
*
* @param carWithObstacle the car that will experience change in y
*/
public ObstacleDecorator(Movable carWithObstacle) {
this.carWithObstacle = carWithObstacle;
}
/**
* This method draws the car with Graphics2D.
*
* @param g2D the reference to Graphics2D
*/
public void drawCar(Graphics2D g2D) {
this.carWithObstacle.drawCar(g2D);
}
/**
* This method changes the coordinate of the car.
*
* @param xChange the change to be made in x coordinate.
* @param yChange the change to be made in y coordinate.
*/
public void translate(int xChange, int yChange) {
this.carWithObstacle.translate(xChange, yChange);
}
/**
* carWithObstacle the car that will go on Hills and bumps
*/
protected Movable carWithObstacle;
}