INsérer un élémént dans un tableau2D
guipe
-
GUIPE Messages postés 98 Statut Membre -
GUIPE Messages postés 98 Statut Membre -
Bonjour, j'ai un tableau 2D dans lequel je voudrais insérer des objets de type Element !
Voici ce que j'ai fait mais ça ne marche pas !
while(i<nb_hopitaux)
{
x_aleatoire=generator.nextInt(20)+1;
y_aleatoire=generator.nextInt(20)+1;
if(elements[x_aleatoire][y_aleatoire]==null)
{
[COLOR="Red"]elements[x_aleatoire][y_aleatoire]=new Hopital(super(x,y),hop.getRepresentation())[/COLOR];
}
else if(elements[x_aleatoire][y_aleatoire]!=null)
{
x_aleatoire=generator.nextInt(20)+1;
y_aleatoire=generator.nextInt(20)+1;
[COLOR="Red"]elements[x_aleatoire][y_aleatoire]=new Hopital(x_aleatoire,y_aleatoire,'H');[/COLOR]
}
}i=0;
Voici ce que j'ai fait mais ça ne marche pas !
while(i<nb_hopitaux)
{
x_aleatoire=generator.nextInt(20)+1;
y_aleatoire=generator.nextInt(20)+1;
if(elements[x_aleatoire][y_aleatoire]==null)
{
[COLOR="Red"]elements[x_aleatoire][y_aleatoire]=new Hopital(super(x,y),hop.getRepresentation())[/COLOR];
}
else if(elements[x_aleatoire][y_aleatoire]!=null)
{
x_aleatoire=generator.nextInt(20)+1;
y_aleatoire=generator.nextInt(20)+1;
[COLOR="Red"]elements[x_aleatoire][y_aleatoire]=new Hopital(x_aleatoire,y_aleatoire,'H');[/COLOR]
}
}i=0;
A voir également:
- INsérer un élémént dans un tableau2D
- Insérer vidéo dans powerpoint - Guide
- Insérer un espace insécable dans word - Guide
- Insérer un sommaire dans word - Guide
- Insérer un tableau dans word - Guide
- Insérer signature word - Guide
3 réponses
Bonjour, j'ai un tableau 2D dans lequel je voudrais insérer des objets de type Element !
Voici ce que j'ai fait mais ça ne marche pas !
while(i<nb_hopitaux)
{
x_aleatoire=generator.nextInt(20)+1;
y_aleatoire=generator.nextInt(20)+1;
if(elements[x_aleatoire][y_aleatoire]==null)
{
elements[x_aleatoire][y_aleatoire]=new Hopital(super(x,y),hop.getRepresentation());
}
else if(elements[x_aleatoire][y_aleatoire]!=null)
{
x_aleatoire=generator.nextInt(20)+1;
y_aleatoire=generator.nextInt(20)+1;
elements[x_aleatoire][y_aleatoire]=new Hopital(x_aleatoire,y_aleatoire,'H');
}
}i=0;
Voici ce que j'ai fait mais ça ne marche pas !
while(i<nb_hopitaux)
{
x_aleatoire=generator.nextInt(20)+1;
y_aleatoire=generator.nextInt(20)+1;
if(elements[x_aleatoire][y_aleatoire]==null)
{
elements[x_aleatoire][y_aleatoire]=new Hopital(super(x,y),hop.getRepresentation());
}
else if(elements[x_aleatoire][y_aleatoire]!=null)
{
x_aleatoire=generator.nextInt(20)+1;
y_aleatoire=generator.nextInt(20)+1;
elements[x_aleatoire][y_aleatoire]=new Hopital(x_aleatoire,y_aleatoire,'H');
}
}i=0;