Class Ball2

java.lang.Object
  extended by BoxedBallsObject
      extended by MoveableObject
          extended by Ball2
All Implemented Interfaces:
Circle, DrawableFigure

public class Ball2
extends MoveableObject
implements Circle

Defines a circular ball(implements interface circle) that has a name, color, mass, velocity, radius, x, and y coordinates.


Constructor Summary
Ball2()
           
Ball2(String name, Color color, double mass, double xVelocity, double yVelocity, double x, double y, double r)
          Creates a ball.
 
Method Summary
 void bounce(Ball2 that)
           
 void bounce(StationaryObject that)
           
 void draw(Graphics canvas)
          Draws the ball onto the canvas at x coordinate - radius, and y coordinate - radius.
 Ball2 getCollidingBallObject()
           
 StationaryObject getCollidingStationaryObject()
           
 boolean getCollisionBallAnswer()
           
 boolean getCollisionWallAnswer()
           
 double getRadius()
           
 double getXCoordinate()
           
 double getYCoordinate()
           
 void setCollidingBallObject(Ball2 that)
           
 void setCollidingStationaryObject(StationaryObject that)
           
 void setCoordinates(double newX_location, double newY_location)
           
 void setCoordinates(double newX_location, double newY_location, double newRadius)
          sets coordinates of circle
 void setRadius(double newRadius)
           
 void setWillCollideWithBallThisTimeStep(boolean expression)
           
 void setWillCollideWithWallThisTimeStep(boolean expression)
           
 double timeToCollision(Ball2 that)
           
 void updatePosition(double dt)
           
 
Methods inherited from class MoveableObject
getColor, getMass, getXVelocity, getYVelocity, setMass, setVelocity
 
Methods inherited from class BoxedBallsObject
getName, setColor, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Ball2

public Ball2()

Ball2

public Ball2(String name,
             Color color,
             double mass,
             double xVelocity,
             double yVelocity,
             double x,
             double y,
             double r)
Creates a ball. The coordinates are at the center of the circular ball.

Parameters:
(name, - color, mass, velocity)
x - x-coordinate
y - y-coordinate
Method Detail

setCoordinates

public void setCoordinates(double newX_location,
                           double newY_location,
                           double newRadius)
Description copied from interface: Circle
sets coordinates of circle

Specified by:
setCoordinates in interface Circle

setCoordinates

public void setCoordinates(double newX_location,
                           double newY_location)
Specified by:
setCoordinates in interface Circle

setRadius

public void setRadius(double newRadius)
Specified by:
setRadius in interface Circle

getXCoordinate

public double getXCoordinate()

getYCoordinate

public double getYCoordinate()

getRadius

public double getRadius()

updatePosition

public void updatePosition(double dt)

timeToCollision

public double timeToCollision(Ball2 that)

bounce

public void bounce(Ball2 that)

bounce

public void bounce(StationaryObject that)

setWillCollideWithWallThisTimeStep

public void setWillCollideWithWallThisTimeStep(boolean expression)

getCollisionWallAnswer

public boolean getCollisionWallAnswer()

setWillCollideWithBallThisTimeStep

public void setWillCollideWithBallThisTimeStep(boolean expression)

getCollisionBallAnswer

public boolean getCollisionBallAnswer()

setCollidingBallObject

public void setCollidingBallObject(Ball2 that)

setCollidingStationaryObject

public void setCollidingStationaryObject(StationaryObject that)

getCollidingBallObject

public Ball2 getCollidingBallObject()

getCollidingStationaryObject

public StationaryObject getCollidingStationaryObject()

draw

public void draw(Graphics canvas)
Draws the ball onto the canvas at x coordinate - radius, and y coordinate - radius. The coordinates defined the center of the circle, but the Graphics paint method inscribes the circle in a square, and defines the upper left corner as the coordinates.

Specified by:
draw in interface DrawableFigure