Skip to content

Instantly share code, notes, and snippets.

@TimDorand
Created April 15, 2016 07:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TimDorand/e562a184c69f9e190744667725738104 to your computer and use it in GitHub Desktop.
Save TimDorand/e562a184c69f9e190744667725738104 to your computer and use it in GitHub Desktop.
private void melangeLesCartes()
{
for (int i = 0 ; i < nbCartes ; i++ ){
// On met un valeur aléatoire dans v
int v = (int) (Math.random() * nbCartes);
// On stocke la valeur alea dans une valeur temporaire
Carte temp = listeCartes[i];
// on met le hasard temp dans la vrai case
listeCartes[i] = listeCartes[v];
listeCartes[v] = temp;
}
}
private void afficherLesCartesAvecEvt()
{
for (int i=0; i< nbCartes; i++)
{
this.boitePhotoPnl.add(listeCartes[i]);
listeCartes[i].addMouseListener(new MouseAdapter(){
@Override
public void mouseReleased(MouseEvent evt){
carteMouseReleased(evt);
}
});
}
}
private void carteMouseReleased(MouseEvent evt)
{
Carte carteCliquee = (Carte) evt.getSource();
carteCliquee.tournerVersFace();
System.out.println("id : "+carteCliquee.getId());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment