// // CannonBall class // Described in Chapter 6 of // Understanding Object-Oriented Programming with Java // by Timothy A Budd // Published by Addison-Wesley // // see ftp://ftp.cs.orst.edu/pub/budd/java/ReadMe.html // for further information // /** * class CannonBall refines class Ball for gravity * * @version 1.0 * @author Timothy Budd * */ public class CannonBall extends Ball { /** * Constructor to init both position, size, and motion * * @param sx the initial x coordinate of the center * @param sy the initial y coordinate of the center * @param r the radius of the cannonball * @param dx the initial delta along the x axis * @param dy the initial delta along the y axis */ public CannonBall (int sx, int sy, int r, double dx, double dy) { super(sx, sy, r); setMotion (dx, dy); } /** * refine move for gravity effects * */ public void move () { dy = dy + 0.3; // effect of gravity super.move(); // update the ball position } }