|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectBall
A small ball object that wanders randomly around a bounded area. CSE143 lecture demo Au01, Sp03, Sp04
Constructor Summary | |
Ball(int x,
int y,
int dx,
int dy,
Color c,
int diameter,
SimModel model)
Construct a new Ball with the given coordinates, initial direction, and model. |
Method Summary | |
void |
action()
Perform an appropriate action on each cycle of the simulation, in this case advancing by dx,dy and reversing either direction if we hit an edge of the simulation. |
void |
paintComponent(Graphics g)
Display this ball on the given graphics context |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Ball(int x, int y, int dx, int dy, Color c, int diameter, SimModel model)
x
- initial x coordinate of center of the bally
- initial y coordinate of center of the balldx
- initial change in x value on each simulation cycledy
- initial change in y value on each simulation cyclec
- color of the balldiameter
- diameter of the ballmodel
- the model that this Ball is a part ofMethod Detail |
public void action()
action
in interface SimThing
public void paintComponent(Graphics g)
paintComponent
in interface SimThing
g
- the graphics context where this ball should be drawn
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |