|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectPinBallDomain.Ball
public class Ball
Object to represent the ball for the PinBall domain.
| Field Summary | |
|---|---|
static double |
DRAG
Drag coefficient |
| Constructor Summary | |
|---|---|
Ball(Point p,
double rad)
Constructs a new ball given a point and radius. |
|
| Method Summary | |
|---|---|
void |
addDrag()
Applies drag to the ball. |
void |
addImpulse(double tox,
double toy)
Add a velocity impulse to the ball. |
static Ball |
create(java.lang.String line)
Creates a ball object from a line in a config file. |
Point |
getCenter()
Obtain the center point of the ball. |
double |
getRadius()
Obtain the ball's radius. |
double |
getVelocity()
Return the ball's speed. |
double |
getX()
Obtain the ball's X co-ordinate |
double |
getXDot()
Obtain the ball's X velocity. |
double |
getY()
Obtain the ball's Y co-ordinate |
double |
getYDot()
Obtain the ball's Y velocity. |
static boolean |
matchTag(java.lang.String line)
Determines whether a config file line refers to the ball. |
void |
setPosition(double xx,
double yy)
Set the ball's position. |
void |
setVelocities(double dx,
double dy)
Explicity set the ball's velocities. |
void |
step()
Moves the ball one step forward, in the direction of xdot and ydot. |
void |
write(java.io.FileWriter f)
Writes the ball to a config file. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final double DRAG
| Constructor Detail |
|---|
public Ball(Point p,
double rad)
p - desired X and Y co-ordinatesrad - desired radius| Method Detail |
|---|
public double getRadius()
public double getX()
public double getY()
public double getXDot()
public double getYDot()
public static boolean matchTag(java.lang.String line)
line - the text line from the config file
true if the line refers to a ball, false otherwisepublic static Ball create(java.lang.String line)
The line specifies the ball's radius, but not it's position, because it may have multiple potential starting positions.
line - the line
Ball
public void write(java.io.FileWriter f)
throws java.io.IOException
f - file to be written to.
java.io.IOExceptionpublic void step()
xdot and ydot.
public void addDrag()
public double getVelocity()
public void addImpulse(double tox,
double toy)
tox - impulse to add to xdottoy - impulse to add to ydot
public void setVelocities(double dx,
double dy)
dx - X velocitydy - Y velocity
public void setPosition(double xx,
double yy)
xx - X positionyy - Y positionpublic Point getCenter()
Point
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||