uwcse.sim
Class PacThing

java.lang.Object
  |
  +--uwcse.sim.PacThing
All Implemented Interfaces:
Thing
Direct Known Subclasses:
Food, MovingThing, Wall

abstract class PacThing
extends java.lang.Object
implements Thing

The basis for every object in the PacMan simulation. Every object has an x,y position and knows about its world.


Field Summary
protected  boolean alive
          A flag representing the life state of this object.
protected static java.util.Random rand
           
protected  WorldModel world
           
protected  int x
           
protected  int y
           
 
Constructor Summary
PacThing(WorldModel wm, int x, int y)
          Create a new PacThing with the given properties.
 
Method Summary
abstract  void action()
          Subclass responsibility.
 void checkNeighbors()
          Call interact on all neighbors.
abstract  void displayOn(uwcse.graphics.GWindow g)
          Subclass responsibility.
 int getX()
          Answer the x position.
 int getY()
          Answer the y position.
 void interact(PacThing t)
          Interact with another PacThing.
 boolean isAlive()
          Answer the alive flag state.
 void kill()
          Set the alive flag to false.
 java.lang.String toString()
          Answer a nice textual representation.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

rand

protected static java.util.Random rand

x

protected int x

y

protected int y

world

protected WorldModel world

alive

protected boolean alive
A flag representing the life state of this object.
Constructor Detail

PacThing

public PacThing(WorldModel wm,
                int x,
                int y)
Create a new PacThing with the given properties.
Method Detail

getX

public int getX()
Answer the x position.
Specified by:
getX in interface Thing

getY

public int getY()
Answer the y position.
Specified by:
getY in interface Thing

action

public abstract void action()
Subclass responsibility.
Specified by:
action in interface Thing

displayOn

public abstract void displayOn(uwcse.graphics.GWindow g)
Subclass responsibility.
Specified by:
displayOn in interface Thing

isAlive

public boolean isAlive()
Answer the alive flag state.
Specified by:
isAlive in interface Thing

kill

public void kill()
Set the alive flag to false.

interact

public void interact(PacThing t)
Interact with another PacThing. Dummy by default.

checkNeighbors

public void checkNeighbors()
Call interact on all neighbors.

toString

public java.lang.String toString()
Answer a nice textual representation.
Overrides:
toString in class java.lang.Object