mirror of
https://gitlab.com/arnekeller/kit-programmieren-ws1920-final1.git
synced 2024-11-24 01:15:05 +00:00
Only place trains if all switches are set
This commit is contained in:
parent
6e62cdb6e0
commit
ba6a939a92
@ -4,6 +4,7 @@ add track (0,15) -> (1,15)
|
||||
add track (1,1) -> (1,14)
|
||||
add switch (1,14) -> (0,14),(1,0)
|
||||
set switch 5 positio (1,0)
|
||||
set switch 2 position (1,0)
|
||||
create engine diesel T3 Emma 1 false true
|
||||
add train 1 T3-Emma
|
||||
create coach passenger 1906 true true
|
||||
@ -13,6 +14,8 @@ add train 1 W1
|
||||
add train 1 W2
|
||||
add train 1 W3
|
||||
put train 1 at (0,0) in direction 0,-1
|
||||
delete track 2
|
||||
add switch (1,14) -> (0,14),(1,0)
|
||||
step -20
|
||||
step 20
|
||||
set switch 5 position (0,14)
|
||||
|
@ -4,6 +4,7 @@ Error, track is not connected to other tracks
|
||||
Error, track is not connected to other tracks
|
||||
2
|
||||
Error, invalid set switch argument syntax
|
||||
OK
|
||||
T3-Emma
|
||||
diesel engine T3-Emma added to train 1
|
||||
1
|
||||
@ -13,6 +14,8 @@ passenger coach W1 added to train 1
|
||||
passenger coach W2 added to train 1
|
||||
Error, could not add rolling stock to train
|
||||
Error, could not place train
|
||||
OK
|
||||
2
|
||||
Error, rail tracks/switches not set up
|
||||
Error, rail tracks/switches not set up
|
||||
Error, could not set switch
|
||||
|
@ -9,4 +9,4 @@ diesel engine T3-Emma added to train 1
|
||||
freight coach W1 added to train 1
|
||||
special coach W2 added to train 1
|
||||
passenger coach W3 added to train 1
|
||||
Error, could not place train
|
||||
Error, switches not set up
|
||||
|
@ -384,6 +384,8 @@ public class ModelRailwaySimulation {
|
||||
throw new InvalidInputException("train is already placed");
|
||||
} else if (direction.getX() != 0 && direction.getY() != 0) {
|
||||
throw new InvalidInputException("invalid train direction");
|
||||
} else if (!railNetwork.isReadyForTrains()) {
|
||||
throw new InvalidInputException("switches not set up");
|
||||
}
|
||||
// attempt to place train
|
||||
boolean placed = train.placeOn(railNetwork, position, direction);
|
||||
|
Loading…
Reference in New Issue
Block a user