-
Notifications
You must be signed in to change notification settings - Fork 0
/
TrackSwitchRightBottom.java
43 lines (38 loc) · 1.38 KB
/
TrackSwitchRightBottom.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
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot und MouseInfo)
/**
* Repräsentiert eine RIGHT-BOTTOM-Switch, d.h. Weiche, die von rechts kommende
* Züge im ungestellten Zustand horizontal leitet, im gestellten Zustand nach unten.
*
* @author Leonard Bienbeck
* @version 1.0.0
*/
public class TrackSwitchRightBottom extends Switch
{
/**
* Erzeugt eine RIGHT-BOTTOM-Switch
*/
public TrackSwitchRightBottom() {
super(TrackType.SWITCH_RIGHTBOTTOM, "switch_right_bottom_");
super.setSwitched(false);
}
public Track determineNextTrack(Direction movingDirection) {
Direction newDirection = null;
switch(movingDirection) {
case LEFT:
newDirection = this.isSwitched() ? Direction.BOTTOM : Direction.LEFT;
break;
default:
newDirection = Direction.RIGHT;
break;
}
return this.getNeighbourAt(newDirection);
}
public Direction getReversedDirection(Direction movingDirection) {
switch(movingDirection) {
case LEFT: return Direction.RIGHT;
case TOP: return this.isSwitched() ? Direction.RIGHT : Direction.BOTTOM;
case RIGHT: return this.isSwitched() ? Direction.TOP : Direction.LEFT;
default: return Direction.RIGHT;
}
}
}