Commit 024c89e3 authored by MostafaRahmati's avatar MostafaRahmati

Everything Is Completed

JavaDoc is next Step
parent db5a7b37
Pipeline #5937 canceled with stages
import java.util.ArrayList;
public class Main {
public static void main(String[] args) {
VotingSystem system = new VotingSystem();
ArrayList<String> singleVoting = new ArrayList<String>();
singleVoting.add("option1");
singleVoting.add("option2");
singleVoting.add("option3");
Voting voting1 = system.createVoting(0,"Enter Selected Option Please..." , singleVoting);
Person person1 = new Person("firstName1","lastName1");
Person person2 = new Person("firstName","lastName2");
Person person3 = new Person("firstName3","lastName3");
Person person4 = new Person("firstName4","lastName4");
system.vote(voting1, person1, "option1");
system.vote(voting1, person2, "option2");
system.vote(voting1, person3, "option3");
system.vote(voting1, person4, "option2");
system.printVotingResult(voting1,0);
ArrayList<String> multipleVoting = new ArrayList<>();
multipleVoting.add("option11");
multipleVoting.add("option21");
multipleVoting.add("option31");
Voting voting2 = system.createVoting(1,"Please Enter Your Choice For Multiple System"
,multipleVoting);
ArrayList<String> person1Votes = new ArrayList<>();
person1Votes.add("option11");
person1Votes.add("option21");
ArrayList<String> person2Votes = new ArrayList<>();
person2Votes.add("option11");
person2Votes.add("option31");
ArrayList<String> person3Votes = new ArrayList<>();
person3Votes.add("option11");
person3Votes.add("option21");
ArrayList<String> person4Votes = new ArrayList<>();
person4Votes.add("option11");
person4Votes.add("option21");
system.vote(voting2, person1, person1Votes);
system.vote(voting2, person2, person2Votes);
system.vote(voting2, person3, person3Votes);
system.vote(voting2, person4, person4Votes);
system.printVotingResult(voting2,1);
}
}
}
\ No newline at end of file
......@@ -64,14 +64,21 @@ public class Voting {
return voters;
}
public void printVotes() {
public void printVotes(int type) {
for (String option : this.options) {
if (!this.polls.containsKey(option)) {
System.out.println(option + " : 0");
}
HashSet<Vote> votes = this.polls.get(option);
System.out.println(option + " : " + votes.size());
if (type==0)
System.out.println(option + " : " + votes.size());
else{
int size=votes.size()-1;
System.out.println(option + " : " + size);
}
}
}
......
......@@ -44,8 +44,8 @@ public class VotingSystem {
}
public void printVotingResult(Voting voting) {
public void printVotingResult(Voting voting, int type) {
System.out.println(voting.getQuestion());
voting.printVotes();
voting.printVotes(type);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment