Utiliser un attribut dans plusieurs classes
Bonjour,
je voudrais pouvoir utiliser un attribut d'une classe (ici une LinkedList) depuis une méthode d'une 2e classe.
Par exemple:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
public class Plateau {
public LinkedList<Integer> listeCellule;
public Plateau() {
listeCellule = new LinkedList<Integer>();
for( int i = 0; i<12 ; i++){
listeCellule.add(4);
}
}
}
public class Joueur {
protected String Nom;
protected int Gain;
public Joueur(String nom) {
this.Nom = nom;
this.Gain = 0;
}
private LinkedList<Integer> jouerCoup(int CelluleAJouer){
//j'ai besoin de listeCellule ici
}
} |
Faut-il que j'instancie obligatoirement un Plateau dans classe Joueur?
Merci