Class Ball

java.lang.Object
  |
  +--Ball

public class Ball
extends java.lang.Object


Constructor Summary
Ball()
          default constructor
Ball(Vector pos, Vector vel, java.awt.Color color)
          Constructor with three parameters viz.
 
Method Summary
 void bounceOffWall(Rectangle rec)
          Set the rebounding velocity of the ball after collision with the table edge
 void collideWithBall(Ball b)
          Set the rebounding velocity of the ball after collision with another ball
 void decelerate(Time t)
          Decelerate the ball
 Time detectBallCollision(Ball b)
          Detect the time of collision with any other ball
 Time detectTableCollision(Rectangle rec)
          Detect the time of collision with any of the table edges
 Time ductStopTime(Duct duct)
          Get the time after which the pocketed ball comes to a stop in the duct
 void endOfDuct(Duct duct)
          Update stationary balls in the duct
 boolean fallIntoHole(Hole hole)
          Check whether the ball has fallen into the hole
 double getAccel()
          Get the acceleration of the ball
 java.awt.Color getColor()
          Get the color of the ball
 Vector getPosition()
          Get the position vector
 double getRadius()
          Get the radius of the ball
 Vector getVelocity()
          Get the velocity of the ball
 boolean isAlive()
          Check whether the ball is on the table
 boolean isMoving()
          Check whether the ball is in motion
 void kill()
          Remove the ball from the table
 void pushIntoDuct(Duct duct)
          Push pocketed ball into duct
 void setAccel(double accel)
          Set the acceleration of the ball
 void setColor(java.awt.Color color)
          Set the color of the ball
 void setPosition(Vector pos)
          Set the position vector
 void setVelocity(Vector vel)
          Set the velocity vector
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Ball

public Ball()
default constructor

Ball

public Ball(Vector pos,
            Vector vel,
            java.awt.Color color)
Constructor with three parameters viz. position, velocity and color
Method Detail

getRadius

public double getRadius()
Get the radius of the ball

setPosition

public void setPosition(Vector pos)
Set the position vector

getPosition

public Vector getPosition()
Get the position vector

setVelocity

public void setVelocity(Vector vel)
Set the velocity vector

getVelocity

public Vector getVelocity()
Get the velocity of the ball

setColor

public void setColor(java.awt.Color color)
Set the color of the ball

getColor

public java.awt.Color getColor()
Get the color of the ball

kill

public void kill()
Remove the ball from the table

isAlive

public boolean isAlive()
Check whether the ball is on the table

isMoving

public boolean isMoving()
Check whether the ball is in motion

getAccel

public double getAccel()
Get the acceleration of the ball

setAccel

public void setAccel(double accel)
Set the acceleration of the ball

fallIntoHole

public boolean fallIntoHole(Hole hole)
Check whether the ball has fallen into the hole

detectTableCollision

public Time detectTableCollision(Rectangle rec)
Detect the time of collision with any of the table edges

detectBallCollision

public Time detectBallCollision(Ball b)
Detect the time of collision with any other ball

bounceOffWall

public void bounceOffWall(Rectangle rec)
Set the rebounding velocity of the ball after collision with the table edge

collideWithBall

public void collideWithBall(Ball b)
Set the rebounding velocity of the ball after collision with another ball

decelerate

public void decelerate(Time t)
Decelerate the ball

ductStopTime

public Time ductStopTime(Duct duct)
Get the time after which the pocketed ball comes to a stop in the duct

pushIntoDuct

public void pushIntoDuct(Duct duct)
Push pocketed ball into duct

endOfDuct

public void endOfDuct(Duct duct)
Update stationary balls in the duct