Commit 1d3b43e7 authored by MostafaRahmati's avatar MostafaRahmati

JavaDoc Added.

parent 22bc950f
Pipeline #5939 failed with stages
import java.util.ArrayList;
public class Main {
/**
* @param args System Args
*
*/
public static void main(String[] args) {
VotingSystem system = new VotingSystem();
ArrayList<String> singleVoting = new ArrayList<String>();
......
......@@ -2,19 +2,32 @@ public class Person {
private String firstName;
private String lastName;
/**
* @param firstName of voter
* @param lastName of voter
*/
public Person(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
/**
* @return first name
*/
public String getFirstName() {
return firstName;
}
/**
* @return last name of voter
*/
public String getLastName() {
return lastName;
}
/**
* @return name of voter attached to his/her last name
*/
@Override
public String toString() {
return firstName + " " + lastName;
......
......@@ -2,23 +2,40 @@ import ir.huri.jcal.JalaliCalendar;
import java.util.Objects;
/**
* class for vote
*/
public class Vote {
private Person person;
private JalaliCalendar date;
/**
* @param person who voted
* @param date jalali date of vote
*/
public Vote(Person person, JalaliCalendar date) {
this.date = date;
this.person = person;
}
/**
* @return voter
*/
public Person getPerson() {
return person;
}
/**
* @return jalali date as a string
*/
public JalaliCalendar getDate() {
return date;
}
/**
* @param o the object being compared
* @return boolean value of equality
*/
@Override
public boolean equals(Object o) {
if (this == o) return true;
......@@ -27,6 +44,9 @@ public class Vote {
return getPerson().equals(vote.getPerson()) && getDate().equals(vote.getDate());
}
/**
* @return hashcode person and date
*/
@Override
public int hashCode() {
return Objects.hash(getPerson(), getDate());
......
......@@ -4,6 +4,9 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
/**
* Voting Class
*/
public class Voting {
private int type;
private String question;
......@@ -11,15 +14,27 @@ public class Voting {
private HashSet<String> options;
private HashMap<String, HashSet<Vote>> polls;
/**
* @return returns the question text
*/
public String getQuestion() {
return question;
}
/**
* @param type type of voting. 0 is single and 1 is multiple
* @param question question text of voting
*/
public Voting(int type, String question) {
this(type, question, new HashSet<>());
}
/**
* @param type type of voting. 0 is single and 1 is multiple
* @param question question text of voting
* @param options options for voting
*/
public Voting(int type, String question, HashSet<String> options) {
this.type = type;
this.question = question;
......@@ -29,10 +44,17 @@ public class Voting {
}
/**
* @param string have no idea what it is
*/
public void createPoll(String string) {
// Not Clarified What It Does In The Documentation
}
/**
* @param person voter
* @param selectedOptions selected options by voter in multiple type
*/
public void vote(Person person, ArrayList<String> selectedOptions) {
this.voters.add(person);
......@@ -51,6 +73,10 @@ public class Voting {
}
/**
* @param person voter
* @param selectedOption selected option by voter in single type
*/
public void vote(Person person, String selectedOption) {
this.voters.add(person);
HashSet<Vote> voteSet = this.polls.containsKey(selectedOption) ?
......@@ -60,10 +86,16 @@ public class Voting {
this.polls.put(selectedOption, voteSet);
}
/**
* @return voters list
*/
public ArrayList<Person> getVoters() {
return voters;
}
/**
* @param type type of voting. 0 is single and 1 is multiple
*/
public void printVotes(int type) {
for (String option : this.options) {
if (!this.polls.containsKey(option)) {
......@@ -82,10 +114,16 @@ public class Voting {
}
}
/**
* @return all polls
*/
public HashMap<String, HashSet<Vote>> getPolls() {
return polls;
}
/**
* @return type of voting
*/
public int getType() {
return type;
}
......
import java.util.ArrayList;
import java.util.HashSet;
/**
* Voting System
*/
public class VotingSystem {
private ArrayList<Voting> votingList;
/**
* Constructor
*/
public VotingSystem() {
this.votingList = new ArrayList<>();
}
/**
* @param type of voting. 0 is single and 1 is multiple
* @param question for voting
* @param optionsList for voting
* @return a vote
*/
public Voting createVoting(int type, String question, ArrayList<String> optionsList) {
HashSet<String> optionsSet = new HashSet<>(optionsList);
Voting voting = new Voting(type, question, optionsSet);
......@@ -17,11 +29,18 @@ public class VotingSystem {
}
/**
* @return a list of votings
*/
public ArrayList<Voting> getVotingList() {
return votingList;
}
/**
* @param type type of voting
* @return a list of voting by type
*/
public ArrayList<Voting> getVoting(int type) {
ArrayList<Voting> sameVoting = new ArrayList<>();
......@@ -34,6 +53,11 @@ public class VotingSystem {
}
/**
* @param voting vote to a specific option
* @param person the voter
* @param selectedOptions options which are selected
*/
public void vote(Voting voting, Person person, ArrayList<String> selectedOptions) {
voting.vote(person, selectedOptions);
}
......
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