edu.lmu.liftor
Class Traveller.VagrantTraveller
java.lang.Object
|
+--edu.lmu.liftor.Traveller
|
+--edu.lmu.liftor.Traveller.VagrantTraveller
- All Implemented Interfaces:
- Person.Personality
- Enclosing class:
- Traveller
- public static class Traveller.VagrantTraveller
- extends Traveller
The vagrant travller is simply a random mover. It hangs out
on a floor for a random amount of time, then hops on an elevator
waiting for another random amount of time until it finally
decides to get off the next time the door opens.
This traveller is completely stateless and so it is offered up as
a singleton VAGRANT. You can get it manually, or call the personality
factory method.
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
getVagrant
public Traveller.VagrantTraveller getVagrant()
- This method returns a vagrant for use in a Person.
getPersonality
public Person.Personality getPersonality()
getName
public java.lang.String getName()
- Description copied from interface:
Person.Personality
- Returns the name of this personality. Preferably an adverb.
- Specified by:
getName in interface Person.Personality- Overrides:
getName in class Traveller
motivate
public int motivate(Person p)
- Description copied from interface:
Person.Personality
- Motivate this person. This method is repeatedly called
so long as this is the given Person's dominant personality.
In essence, it should decide upon a goal, execute that goal,
then return so that it may be called again to repeat the goal
selection and execution process.
A personality may take as little or as long as it wants to
complete its objective, it may even decide to store state
and return knowing it will (most likely) be called again.
The number that is returned is the number of milliseconds
that the Personality is willing to wait for another chance
to execute. While there is no guarantee that motivate()
will be called again within that time, it allows the
use of a thread pool to move persons around in the
game.
If the quantity returned is negative, that is the maximum amount
of time that the Personality would like to have elapse
before the next call. If it is a postive number, that is the
minimum amount of time and the Personality is willing to allow
more time to elapse if necessary.