Class Person
java.lang.Object
|
+----Person
- public class Person
- extends Object
- implements Runnable
The Person class represents a person as part of the Bridges
simulation.
A Person
is a Runnable
object, meaning that it
can be run as a separate thread. The only goal in life of a person is
to get to the other side of the river. (Perhaps it should be called a
chicken?)
- See Also:
- Bridges
-
Person(Bridges, int)
- Construct a Person trying to cross a particular river in a particular
direction.
-
run()
- Try to get across the river.
-
toString()
- Returns a string representation of the Person.
Person
public Person(Bridges river,
int direction)
- Construct a Person trying to cross a particular river in a particular
direction.
- Parameters:
- river - a
Bridges
object representing a river with
bridges over it.
- direction - the desired direction to cross -- one of GOEAST or
GOWEST.
- See Also:
- GOEAST, GOWEST
toString
public String toString()
- Returns a string representation of the Person.
- Returns:
- a string representation of this
Person
object.
- Overrides:
- toString in class Object
run
public void run()
- Try to get across the river.
Print a message when starting and another after successfully crossing.
This procedures returns (causing the thread that is running it to
terminate) after it prints the second message.