import java.applet.Applet; import java.awt.*; import java.net.URL; public class raceField extends Applet implements Runnable{ private Car [] cars; private long lastUpdateTime; private boolean haveWinner; private Thread thread; public void init(){ cars = new Car[4]; Image img; try{ URL url = new URL (this.getCodeBase(),"car.gif"); img = this.getImage(url); } catch (Exception e){ img = null; } cars[0] = new Car(0, 1, 2, img); cars[1] = new Car(0, 4, 4, img); cars[2] = new Car(0, 2, 3, img); cars[3] = new Car(0, 3, 2, img); } public void paint (Graphics g){ for (cars=0; cars<=4; cars++){ g.drawImage(cars); } } public void Start(){ thread = new Thread(this); haveWinner = false; thread.start(); } public void Run(){ while(!haveWinner){ this.repaint(); try{ Thread.sleep(100); } catch (InterruptedException e){} } } }