j'ai une code sourse initiale pour ce projet
**************class piste*****************
import java.awt.*;
public class Piste extends Frame{
int hauteur=380;
int largeur=500;
public Piste(String Titre ,int h ,int l){
super(Titre);
hauteur=h;
largeur=l;
setSize(largeur,hauteur);
setVisible(true);
}
}
************class cours*********
import java.awt.*;
public class Cours{
public static void main(String[] args){
Piste p=new Piste("Exemple Course SIL",300,1000);
Auto[] m=new Auto[4];
Thread[]t=new Thread[4];
m[0]=new Auto(Color.red,new int[]{0,0},new int[]{206,0},"Ahemd");
m[1]=new Auto(Color.blue,new int[]{0,50},new int[]{206,50},"Ali");
m[2]=new Auto(Color.green,new int[]{0,100},new int[]{260,100},"Alice");
m[3]=new Auto(Color.yellow,new int[]{0,150},new int[]{206,150},"BOB");
p.setLayout(new GridLayout(4,1));
for (int i=0;i<4 ;i++){
t[i]=new Thread(m[i]);
p.add(m[i]);
}
p.validate();
for(int i=0;i<4 ;i++){
t[i].start();
}
}
}
***********class auto*************
import java.awt.*;
public class Auto extends Canvas implements Runnable{
int posx,posy;
Color couleur= Color.blue;
int[]Depart={0,0} ;
int[]Arrive={0,0} ;
int vitesse;
String Pilote =new String ("ananyme");
Auto(){
setSize(120,50);
posx=0;
posy=0;
}
Auto(Color c,int[]dep ,int[]arrive,String p){
setSize(120,50);
posx=dep[0];
posy=0;
Arrive[0]=arrive[0];
Arrive[1]=0;
couleur=c;
Pilote=p;
vitesse=(int)Math.floor(Math.random()*100);
}
public void paint(Graphics g){
g.setColor(couleur);
g.fillRect(posx,posy+20,120,30);
g.setColor(Color.BLACK);
g.fillRect(posx,posy+15,120,30);
g.fillRect(posx,posy+10,120,25);
g.fillOval(posx+10,posy+32,30,30);
g.fillOval(posx+75,posy+32,30,30);
g.setColor(Color.white);
g.drawString(Pilote,posx+10,posy+30);
g.setColor(couleur);
}
public void avancer(int dx ,int dy){
posx+=Math.cos(dx)*10;
repaint();
System.out.println("("+posx+","+posy+")");
}
public void run(){
while(posx
Autres questions qui peuvent vous aider

1
