PinBallDomain
Class Target

java.lang.Object
  extended by PinBallDomain.Target
All Implemented Interfaces:
Obstacle

public class Target
extends java.lang.Object
implements Obstacle

The goal in the PinBallDomain.

Author:
George Konidaris (gdk at cs dot umass dot edu)

Constructor Summary
Target(Point P, double rad)
          Create a new target.
 
Method Summary
 boolean collision(Ball b)
          Determine whether a collision takes place with the ball.
 double[] collisionEffect(Ball b)
          Compute collision effect with the ball.
static Target create(java.lang.String line)
          Create a new target given a line of config file text.
 Point getCenter()
          Get the center of the target.
 Point getIntercept()
          Get a point of intersection.
 double getRadius()
          Get the target's radius.
 double getX()
          Get the target's X coordinate.
 double getY()
          Get the target's Y coordinate.
 boolean inside(Point p)
          Determine whether a point is inside the target.
static boolean matchTag(java.lang.String line)
          Determine whether a line of the config file refers to the target.
 void write(java.io.FileWriter f)
          Write the target object to a file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Target

public Target(Point P,
              double rad)
Create a new target.

Parameters:
P - center
rad - radius
Method Detail

collisionEffect

public double[] collisionEffect(Ball b)
Compute collision effect with the ball.

Specified by:
collisionEffect in interface Obstacle
Parameters:
b - the ball
Returns:
the effect: (0, 0) since the target is absorbing

getCenter

public Point getCenter()
Get the center of the target.

Returns:
the center point

collision

public boolean collision(Ball b)
Determine whether a collision takes place with the ball.

Specified by:
collision in interface Obstacle
Parameters:
b - the ball
Returns:
true if there has been a collision, false otherwise

inside

public boolean inside(Point p)
Determine whether a point is inside the target.

Specified by:
inside in interface Obstacle
Parameters:
p - point to check
Returns:
true if p lies within the target, false otherwise.

matchTag

public static boolean matchTag(java.lang.String line)
Determine whether a line of the config file refers to the target.

Parameters:
line - the line of config file text
Returns:
true if the line matches, false if it doesn't

create

public static Target create(java.lang.String line)
Create a new target given a line of config file text.

Parameters:
line - the config file line
Returns:
a newly created Target object

write

public void write(java.io.FileWriter f)
           throws java.io.IOException
Write the target object to a file.

Specified by:
write in interface Obstacle
Parameters:
f - the file
Throws:
java.io.IOException

getIntercept

public Point getIntercept()
Get a point of intersection.

Specified by:
getIntercept in interface Obstacle
Returns:
null, always

getX

public double getX()
Get the target's X coordinate.

Returns:
the X coordinate

getY

public double getY()
Get the target's Y coordinate.

Returns:
the Y coordinate

getRadius

public double getRadius()
Get the target's radius.

Returns:
the radius