import java.applet.Applet;
import java.awt.*;

/** Taken from Core Web Programming from 
 *  Prentice Hall and Sun Microsystems Press,
 *  http://www.corewebprogramming.com/.
 *  &copy; 2001 Marty Hall and Larry Brown;
 *  may be freely used or adapted.
 */

public class ShipSimulation extends Applet implements Runnable {
  ...
  
  public void run() {
    Ship s;
    for(int i=0; i<ships.length; i++) {
      s = ships[i];
      s.move(); // Update location.
    }
    repaint();
  }

  ...
  
  public void paint(Graphics g) {
    Ship s;
    for(int i=0; i<ships.length; i++) {
      s = ships[i];
      g.draw(s); // Draw at current location.
    }
  }
}
