forked from daveagp/java_visualize
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChoix.java
More file actions
52 lines (52 loc) · 1.16 KB
/
Choix.java
File metadata and controls
52 lines (52 loc) · 1.16 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package studs;
import java.util.List;
import java.util.Vector;
public abstract class Choix {
private List<Bulletin> lesBulletins;
int nbBulletinsPour, nbBulletinsContre;
public Choix() {
lesBulletins = new Vector<Bulletin>();
nbBulletinsPour = 0;
nbBulletinsContre = 0;
}
public int addBulletin(Bulletin b) {
lesBulletins.add(b);
if(b.getValue()){
nbBulletinsPour++ ;
} else {
nbBulletinsContre++ ;
}
return lesBulletins.size();
}
public int getNbBulletinsPour() {
return nbBulletinsPour;
}
public int getNbBulletinsContre(){
return nbBulletinsContre;
}
public void retirerBulletin(final Bulletin retrait) {
if(lesBulletins.remove(retrait)){
if(retrait.getValue()) {
nbBulletinsPour-- ;
} else {
nbBulletinsContre-- ;
}
}
}
public void modifierBulletin(final Bulletin changed) {
int rang = lesBulletins.indexOf(changed);
if (rang >=0) {
Bulletin aChanger = lesBulletins.get(rang);
if (aChanger.getValue() != changed.getValue()) {
aChanger.setValue(changed.getValue());
}
if (aChanger.getValue()) {
nbBulletinsContre-- ;
nbBulletinsPour++;
} else {
nbBulletinsContre++ ;
nbBulletinsPour--;
}
}
}
}