|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--FlyManager
CLASS: FlyManager
PURPOSE: This class is the monitor of where the flies are and to manage them
IMPORT: java.util.Vector, java.awt.Image, java.awt.Graphics,
java.awt.image.ImageObserver, Fly
EXPORT: New Class|FlyManager
New Method| FlyManager, createFly, eatFly
moveAllFly, paintAllFly
Field Summary | |
private java.util.Vector |
flyList
Keep track of the list of flies |
private int |
height
height of the box where the fly is allow to go |
private int |
maxFly
Maximum number of flies alive at any given time |
private int |
maxMovement
how far the flies can move |
private int |
width
width of the box where the fly is allow to go |
Constructor Summary | |
FlyManager(int max,
int w,
int h)
PRE: NONE POST: Save the configuration information |
Method Summary | |
boolean |
createFly()
PRE: NONE POST: A fly is created if the maximum number of fly has not been reach yet |
boolean |
eatFly(int x,
int y)
PRE: NONE POST: Try to eat the fly, if fail return false, otherwise, return true and the fly will be removed |
void |
moveAllFly()
PRE: NONE POST: move all the flies' position randomly |
void |
paintAllFly(java.awt.Graphics g,
java.awt.Image flyImage,
java.awt.image.ImageObserver appletRef)
PRE: Valid instance of Graphics, Image, and ImageObserver POST: Paint all the flies available onto the Graphics object |
Methods inherited from class java.lang.Object |
|
Field Detail |
private java.util.Vector flyList
private int width
private int height
private int maxFly
private int maxMovement
Constructor Detail |
public FlyManager(int max, int w, int h)
Method Detail |
public boolean createFly()
public boolean eatFly(int x, int y)
public void paintAllFly(java.awt.Graphics g, java.awt.Image flyImage, java.awt.image.ImageObserver appletRef)
public void moveAllFly()
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |