A voir également:
- Random java
- Waptrick java football - Télécharger - Jeux vidéo
- Java apk - Télécharger - Langages
- Jeux java football - Télécharger - Jeux vidéo
- Java jre - Télécharger - Langages
- Télécharger jeux java gameloft gratuit - Forum Mobile
3 réponses
zagor5
Messages postés
187
Date d'inscription
lundi 3 février 2003
Statut
Membre
Dernière intervention
21 octobre 2005
32
30 déc. 2004 à 23:23
30 déc. 2004 à 23:23
Pour prendre la date en court, il faut juste utiliser Date date=new Date(); .
Si ta boucle s'execute en moins d'une seconde, la valeur nbrPourInitialiser sera toujours la même.
Je te conseil de sortir de ta boucle l'initialisation du random.
Plus ça rate, plus on a de chances que ça marche.
Si ta boucle s'execute en moins d'une seconde, la valeur nbrPourInitialiser sera toujours la même.
Je te conseil de sortir de ta boucle l'initialisation du random.
public void actionPerformed(ActionEvent evt){ Random r = new Random(); Date date=new Date(); int nbrPourInitialiser=date.getSeconds(); r.setSeed((long)nbrPourInitialiser); System.out.println(nbrPourInitialiser); for(int i=0;i<6;i++){ int n= r.nextInt(49); String s =""+n; boutons[i].setText(s); } }
Plus ça rate, plus on a de chances que ça marche.
bonjour,
j'ai un probleme dans mon pg c ke quand j'affiche ma matrice de vector il me l'affiche aléatoirement c ca ke je veuw faire mais ya des objets ki manquent a chaque fois .
voici le bout de mon pg
x=r1.nextInt(10);y=r2.nextInt(10);
while ((compt<10) && (tab[x][y]== null)){
Vector fourmi=new Vector();
fourmi.addElement(new Integer(compt));
tab[x][y]=fourmi;compt=compt+1;
x=r3.nextInt(10);y=r4.nextInt(10);
}
for(int i=0;i<10 ;i++){
for(int j=0;j<10;j++){
System.out.println(tab[i][j]);
j'ai un probleme dans mon pg c ke quand j'affiche ma matrice de vector il me l'affiche aléatoirement c ca ke je veuw faire mais ya des objets ki manquent a chaque fois .
voici le bout de mon pg
x=r1.nextInt(10);y=r2.nextInt(10);
while ((compt<10) && (tab[x][y]== null)){
Vector fourmi=new Vector();
fourmi.addElement(new Integer(compt));
tab[x][y]=fourmi;compt=compt+1;
x=r3.nextInt(10);y=r4.nextInt(10);
}
for(int i=0;i<10 ;i++){
for(int j=0;j<10;j++){
System.out.println(tab[i][j]);