Commit 22bc950f authored by MostafaRahmati's avatar MostafaRahmati

Clean Code

parent 024c89e3
Pipeline #5938 canceled with stages
......@@ -9,27 +9,27 @@ public class Main {
singleVoting.add("option2");
singleVoting.add("option3");
Voting voting1 = system.createVoting(0,"Enter Selected Option Please..." , singleVoting);
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");
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);
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);
Voting voting2 = system.createVoting(1, "Please Enter Your Choice For Multiple System"
, multipleVoting);
ArrayList<String> person1Votes = new ArrayList<>();
person1Votes.add("option11");
......@@ -52,7 +52,7 @@ public class Main {
system.vote(voting2, person3, person3Votes);
system.vote(voting2, person4, person4Votes);
system.printVotingResult(voting2,1);
system.printVotingResult(voting2, 1);
}
}
\ No newline at end of file
public class Person {
private String firstName;
private String lastName;
public Person(String firstName, String lastName){
this.firstName=firstName;
this.lastName=lastName;
public Person(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
public String getFirstName() {
......@@ -16,6 +17,6 @@ public class Person {
@Override
public String toString() {
return firstName+" "+lastName;
return firstName + " " + lastName;
}
}
......@@ -71,10 +71,10 @@ public class Voting {
}
HashSet<Vote> votes = this.polls.get(option);
if (type==0)
if (type == 0)
System.out.println(option + " : " + votes.size());
else{
int size=votes.size()-1;
else {
int size = votes.size() - 1;
System.out.println(option + " : " + size);
}
......
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