// // FILE: CannonBall.java // AUTHOR: Eugene Wallingford // DATE: 2012/10/08 // COMMENT: This class is based on Tim Budd's original CannonWorld // and adapted for CS 2530. // // MODIFIED: 2012/10/23 -- Eugene Wallingford // CHANGE: Added nextColor(), which cycles the color through // blue/red/yellow // import java.awt.Color; public class CannonBall extends Ball { public CannonBall( int startX, int startY, int radius, double deltaX, double deltaY ) { super( startX, startY, radius, deltaX, deltaY ); } public void move() { adjustSpeedBy( 0.0, 0.3 ); // record the effect of gravity super.move(); // and update my position } public void nextColor() { if ( color().equals( Color.blue ) ) become( Color.red ); else if ( color().equals( Color.red ) ) become( Color.yellow ); else // ( color().equals( Color.yellow ) ) become( Color.blue ); } }