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
38 lines (38 loc) · 1.18 KB
/
Personne.java
File metadata and controls
38 lines (38 loc) · 1.18 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
37
38
package studsclone;
import java.util.ArrayList;
import studsabstract.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. */
@Override
public Personne clone() throws CloneNotSupportedException {
Personne cl = new Personne(new String(nom), new String(prenom));
cl.nbParticipations = nbParticipations;
cl.nbOrg = nbOrg;
for (Scrutin scr : scrutins ) {
Scrutin sclone = scr.clone();
sclone.setOrganisateur(cl);
cl.scrutins.add(sclone);
}
return cl;
}
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) { }
}