public class Tunnel
extends java.lang.Object
Tunnel
represents the tunnel between two open Portal
s,
which are the tunnel entrances. A Tunnel
has a single section of Rail
s
inside with a given length, on which vehicles can traverse. It can be opened, checked for
traffic and closed.Constructor and Description |
---|
Tunnel(Portal portal1,
Portal portal2,
int length)
Creates a
Tunnel between portal1 and portal2 containing
a number of Rail s given by length . |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes both of the entrances of this
Tunnel . |
boolean |
isEmpty()
Returns if there are any
Vehicles occupying any of the Rail s
inside the Tunnel . |
public Tunnel(Portal portal1, Portal portal2, int length)
Tunnel
between portal1
and portal2
containing
a number of Rail
s given by length
.portal1
- one of the entrances of the Tunnel
. A Portal
to be opened.portal2
- another entrance for the Tunnel
. A Portal
to be opened.length
- the number of Rail
s to be in the Tunnel