-
Notifications
You must be signed in to change notification settings - Fork 0
/
VotingSystem.java
80 lines (70 loc) · 1.88 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package com.company;
import java.util.ArrayList;
/**
* create a voting System
*/
public class VotingSystem {
//list of voting
private ArrayList<Voting> votingList;
/**
* create list of voting
*/
public VotingSystem(){
votingList = new ArrayList<Voting>();
}
/**
* create a voting
* @param question question of voting
* @param type type of voting
* @param choices chocies of voting
*/
public void createVoting(String question, int type, ArrayList<String> choices){
Voting voting = new Voting(type, question);
votingList.add(voting);
for (String s : choices){
voting.creatChoice(s);
}
}
/**
* prints votings questions
*/
public void printVotingQuestion(){
for (Voting voting : votingList){
System.out.println(voting.getQuestion());
}
}
/**
* print question of voting and its choices
* @param index index of voting in list
*/
public void printVoting(int index){
System.out.println(votingList.get(index).getQuestion());
ArrayList<String> choices = new ArrayList<String>();
choices = votingList.get(index).getChoices();
for (String s : choices){
System.out.println(s);
}
}
/**
* a person vote in chosen voting
* @param index index of voting
* @param person person who votes
* @param votes his choices
*/
public void vote(int index,Person person,ArrayList<String> votes){
votingList.get(index).vote(person,votes);
}
/**
* print result of voting
* @param index index of voting in the list
*/
public void printResults(int index){
votingList.get(index).printVotes();
}
/**
* @return list of votings
*/
public ArrayList<Voting> getVotingList() {
return votingList;
}
}