-
Notifications
You must be signed in to change notification settings - Fork 0
/
TrackCurveTopRight.java
39 lines (35 loc) · 1.1 KB
/
TrackCurveTopRight.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
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot und MouseInfo)
/**
* Repräsentiert eine Gleis-Kurve, die TOP und RIGHT verbindet, d.h. eine bestimmte Art von Track.
*
* @author Leonard Bienbeck
* @version 1.0.0
*/
public class TrackCurveTopRight extends Track
{
/**
* Erzeugt eine neue Gleis-Kurve, die TOP und RIGHT verbindet.
*/
public TrackCurveTopRight() {
super(TrackType.CURVE_TOPRIGHT);
}
public Track determineNextTrack(Direction movingDirection) {
Direction newDirection = null;
switch(movingDirection) {
case BOTTOM:
newDirection = Direction.RIGHT;
break;
case LEFT:
newDirection = Direction.TOP;
break;
}
return this.getNeighbourAt(newDirection);
}
public Direction getReversedDirection(Direction movingDirection) {
switch(movingDirection) {
case LEFT: return Direction.BOTTOM;
case BOTTOM: return Direction.LEFT;
default: return Direction.BOTTOM;
}
}
}