|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.kolls.railworld.play.Trains
public class Trains
The list of trains. Includes behavior for trains and train processing.
| Constructor Summary | |
|---|---|
Trains(javax.swing.JPanel tchr,
javax.swing.JList tl)
Create a train list with a particular controller panel and a visual list. |
|
| Method Summary | |
|---|---|
void |
add(int index,
Train t)
Add a new train to the collection at the specified index. |
void |
add(Train t)
Add a new a train to the collection. |
void |
addListDataListener(javax.swing.event.ListDataListener l)
|
Train |
get(int index)
Get a train |
java.lang.Object |
getElementAt(int index)
|
Car |
getSelectedCar()
|
Train |
getSelectedTrain()
|
int |
getSize()
|
java.util.Iterator<Train> |
iterator()
|
Train |
join(Train t1,
Train t2)
Joins two trains. |
void |
refreshList()
Inform the list listeners that the entire list may have changed. |
void |
remove(int index)
Remove a train |
void |
remove(Train t)
Remove a given train from the map. |
void |
removeListDataListener(javax.swing.event.ListDataListener l)
|
Train |
reverse(Train t)
Reverse the direction of a given train. |
void |
select(Train t,
Car c)
Select a particular train, and optionally, a particular car. |
int |
size()
How many trains are being managed. |
Train |
split(Train t)
Splits a given train based on the selected car. |
void |
step()
Process all train behavior for one step. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Trains(javax.swing.JPanel tchr,
javax.swing.JList tl)
tchr - A JPanel to display the selected train's controller.tl - A JList to display the list of trains.| Method Detail |
|---|
public Train getSelectedTrain()
Train, if any.public Car getSelectedCar()
Car within the selected train, if any.
public void select(Train t,
Car c)
t - The Train to select. May be null.c - The Car to select. If null, the controller may select the first car in the train by default.public Train reverse(Train t)
t - The train to reverse. This train will be removed from the list
public Train split(Train t)
t - The train to split.
public Train join(Train t1,
Train t2)
t1 - t2 -
public void step()
throws RailAccident
RailAccident - If an accident occurs.public void addListDataListener(javax.swing.event.ListDataListener l)
addListDataListener in interface javax.swing.ListModelpublic java.lang.Object getElementAt(int index)
getElementAt in interface javax.swing.ListModelpublic int getSize()
getSize in interface javax.swing.ListModelpublic void removeListDataListener(javax.swing.event.ListDataListener l)
removeListDataListener in interface javax.swing.ListModelpublic void add(Train t)
t - The train to add.
public void add(int index,
Train t)
index - Index to add train att - The train to addpublic Train get(int index)
index - The index of the train to get
public void remove(int index)
index - The index of the train to removepublic void remove(Train t)
t - Train to remove.public int size()
public java.util.Iterator<Train> iterator()
iterator in interface java.lang.Iterable<Train>public void refreshList()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||