forked from daveagp/java_visualize
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPersonne.java
More file actions
36 lines (35 loc) · 1.15 KB
/
Personne.java
File metadata and controls
36 lines (35 loc) · 1.15 KB
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
29
30
31
32
33
34
35
36
package studsclonedeep;
import java.util.ArrayList;
import studs.Bulletin;
public class Personne implements Cloneable {
private String nom, prenom;
private int nbParticipations = 0, nbOrg = 0;
private ArrayList<Scrutin> scrutins;
public Personne(final String n, final String p) {
this.nom = n;
this.prenom = p;
scrutins = new ArrayList<Scrutin>();
}
public Scrutin organiserScrutin(final String nom) {
Scrutin s = new Scrutin(nom,this);
scrutins.add(s);
nbOrg ++;
return s;
}
/** le clonage est profond, il duplique les objets references */
@SuppressWarnings("unchecked")
@Override
public Personne clone() throws CloneNotSupportedException {
Personne clone = new Personne(new String(nom), new String(prenom));
clone.nbParticipations = nbParticipations;
clone.nbOrg = nbOrg;
clone.scrutins = (ArrayList<Scrutin>) scrutins.clone();
return clone;
}
public String getNom() { return nom; }
public String getPrenom() {return prenom; }
public ArrayList<Scrutin> getScrutins() {return scrutins; }
public void voter(final Bulletin b){ }
public void consulterResultat(Scrutin s) { }
public void seRetirerDUnScrutin(Scrutin s) { }
}