@@ -0,0 +1,2505 @@
+import collisionphysics.CollisionPhysics;%0Aimport collisionphysics.CollisionResponse;%0A%0Aimport java.awt.*;%0Aimport java.util.Formatter;%0A%0A/**%0A * The bouncing ball.%0A *%0A * @author Hock-Chuan Chua%0A * @version v0.4 (31 October 2010)%0A */%0Apublic class Ball extends DefaultMovable implements Movable %7B%0A  private Color color;  // Ball's color%0A  private static final Color DEFAULT_COLOR = Color.BLUE;%0A%0A  /**%0A   * Constructor: For user friendliness, user specifies velocity in speed and%0A   * moveAngle in usual Cartesian coordinates. Need to convert to speedX and%0A   * speedY in Java graphics coordinates for ease of operation.%0A   */%0A  public Ball(float x, float y, float radius, float speed, float angleInDegree, Color color) %7B%0A    this.x = x;%0A    this.y = y;%0A    // Convert (speed, angle) to (x, y), with y-axis inverted%0A    this.speedX = (float) (speed * Math.cos(Math.toRadians(angleInDegree)));%0A    this.speedY = (float) (-speed * (float) Math.sin(Math.toRadians(angleInDegree)));%0A    this.radius = radius;%0A    this.color = color;%0A  %7D%0A%0A  /**%0A   * Constructor with the default color%0A   */%0A  public Ball(float x, float y, float radius, float speed, float angleInDegree) %7B%0A    this(x, y, radius, speed, angleInDegree, DEFAULT_COLOR);%0A  %7D%0A%0A  /**%0A   * Draw itself using the given graphics context.%0A   */%0A  public void draw(Graphics g) %7B%0A    g.setColor(color);%0A    g.fillOval((int) (x - radius), (int) (y - radius), (int) (2 * radius),%0A        (int) (2 * radius));%0A  %7D%0A%0A  /**%0A   * Return the magnitude of speed.%0A   */%0A  public float getSpeed() %7B%0A    return (float) Math.sqrt(speedX * speedX + speedY * speedY);%0A  %7D%0A%0A  /**%0A   * Return the direction of movement in degrees (counter-clockwise).%0A   */%0A  public float getMoveAngle() %7B%0A    return (float) Math.toDegrees(Math.atan2(-speedY, speedX));%0A  %7D%0A%0A  /**%0A   * Return mass%0A   */%0A  public float getMass() %7B%0A    return radius * radius * radius / 1000f;%0A  %7D%0A%0A  /**%0A   * Return the kinetic energy (0.5mv%5E2)%0A   */%0A  public float getKineticEnergy() %7B%0A    return 0.5f * getMass() * (speedX * speedX + speedY * speedY);%0A  %7D%0A%0A  /**%0A   * Describe itself.%0A   */%0A  public String toString() %7B%0A    sb.delete(0, sb.length());%0A    formatter.format(%22@(%253.0f,%253.0f) r=%253.0f V=(%253.0f,%253.0f) %22 +%0A            %22S=%254.1f %5Cu0398=%254.0f KE=%253.0f%22,%0A        x, y, radius, speedX, speedY, getSpeed(), getMoveAngle(),%0A        getKineticEnergy());  // %5Cu0398 is theta%0A    return sb.toString();%0A  %7D%0A%0A  private StringBuilder sb = new StringBuilder();%0A  private Formatter formatter = new Formatter(sb);%0A%0A%7D%0A

Create Ball.java