-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVotingSystem.java
39 lines (33 loc) · 1.01 KB
/
VotingSystem.java
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
import java.util.ArrayList;
public class VotingSystem {
private ArrayList<Voting> votingList;
public VotingSystem() {
this.votingList = new ArrayList<>();
}
public void createVoting(String question, boolean isAnonymous, int type, ArrayList<String> options) {
votingList.add(new Voting(type, question, isAnonymous, options));
}
public Voting getVoting(int index) {
if (index >= 0 && index < votingList.size()) {
return votingList.get(index);
} else {
return null;
}
}
public void printVoting(int index) {
Voting voting = getVoting(index);
if (voting != null) {
voting.printResults();
} else {
System.out.println("Voting not found.");
}
}
public void printVoters(int index) {
Voting voting = getVoting(index);
if (voting != null) {
voting.printVoters();
} else {
System.out.println("Voting not found.");
}
}
}