edu.lmu.liftor
Class Person

java.lang.Object
  |
  +--edu.lmu.liftor.Person
All Implemented Interfaces:
java.lang.Runnable, Visitor

public class Person
extends java.lang.Object
implements Visitor, java.lang.Runnable

A person is a mobile visitor that has a personality and runs about.


Nested Class Summary
static class Person.Deity
          The Deity class manages the heap of runnable people and tosses them into its private thread pool when they are ready to run.
static class Person.PeopleRuntimeComparator
           
static interface Person.Personality
          A personality is used to control the behavior of a person.
 
Field Summary
static Person.Deity loki
           
 java.lang.String name
           
static Person.Personality SLACKER
          The slacker is a personality that simply sleeps.
 
Constructor Summary
Person(java.lang.String name, Person.Personality p, Place startAt, Person.Deity d)
          Create a person with the given name.
 
Method Summary
 void convert(Person.Deity d)
           
 java.lang.String getName()
           
static Person getNewPerson()
          This returns a brand new slacker.
static Person getNewPerson(Person.Personality personality)
          A factory that creates a new person.
 Person.Personality getPersonality()
           
 Place getPlace()
          Get the place that this person is currently at.
 void run()
          This run method returns after this Person has been placed back into the run queue.
 void setPersonality(Person.Personality p)
           
 void start()
          Get this Person started running.
 java.lang.String toString()
           
 void youAreHere(Place newPlace)
          A signal that the Visitor has successfully entered a place.
 void youHaveLeft(Place p)
          A signal that the Visitor has left a place.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

public final java.lang.String name

loki

public static final Person.Deity loki

SLACKER

public static final Person.Personality SLACKER
The slacker is a personality that simply sleeps. All the time.

Constructor Detail

Person

public Person(java.lang.String name,
              Person.Personality p,
              Place startAt,
              Person.Deity d)
Create a person with the given name.

Method Detail

getName

public java.lang.String getName()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getPlace

public Place getPlace()
Get the place that this person is currently at.


convert

public void convert(Person.Deity d)

setPersonality

public void setPersonality(Person.Personality p)

getPersonality

public Person.Personality getPersonality()

start

public void start()
Get this Person started running. This adds this person to the PeopleQ and initializes the PQ if need be.

Specified by:
start in interface Visitor

run

public void run()
This run method returns after this Person has been placed back into the run queue.

Specified by:
run in interface java.lang.Runnable

youAreHere

public void youAreHere(Place newPlace)
Description copied from interface: Visitor
A signal that the Visitor has successfully entered a place. This method is not called unless the visitor is already at the given place.

Specified by:
youAreHere in interface Visitor

youHaveLeft

public void youHaveLeft(Place p)
Description copied from interface: Visitor
A signal that the Visitor has left a place. This method is not called unless the visitor is already out of the given place.

Specified by:
youHaveLeft in interface Visitor

getNewPerson

public static Person getNewPerson(Person.Personality personality)
A factory that creates a new person.


getNewPerson

public static Person getNewPerson()
This returns a brand new slacker.