uwcse.sim
Class AbstractParticle

java.lang.Object
  |
  +--uwcse.sim.AbstractParticle
All Implemented Interfaces:
Thing
Direct Known Subclasses:
Canon, Firework

abstract class AbstractParticle
extends java.lang.Object
implements Thing

A basic particle. It has x and y position, as well as velocity in the x and y direction.


Field Summary
protected  int age
           
(package private) static java.util.Random rand
           
protected  int velX
           
protected  int velY
           
protected  WorldModel world
           
protected  int x
           
protected  int y
           
 
Constructor Summary
AbstractParticle(WorldModel w, int x, int y, int velX, int velY)
          Create a new particle with the given properties.
 
Method Summary
 void action()
          Just update age and x and y position, based on velocity.
abstract  void displayOn(uwcse.graphics.GWindow g)
          Subclasses must implement.
 int getX()
          Answer the x position.
 int getY()
          Answer the y position.
 boolean isAlive()
          Always alive by default.
 java.lang.String toString()
          Answer a string representation.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

protected int x

y

protected int y

velX

protected int velX

velY

protected int velY

age

protected int age

world

protected WorldModel world

rand

static java.util.Random rand
Constructor Detail

AbstractParticle

public AbstractParticle(WorldModel w,
                        int x,
                        int y,
                        int velX,
                        int velY)
Create a new particle 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 void action()
Just update age and x and y position, based on velocity.
Specified by:
action in interface Thing

displayOn

public abstract void displayOn(uwcse.graphics.GWindow g)
Subclasses must implement.
Specified by:
displayOn in interface Thing

isAlive

public boolean isAlive()
Always alive by default.
Specified by:
isAlive in interface Thing

toString

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