Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Mohammad Mahdi Malmasi/.DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions Mohammad Mahdi Malmasi/studentNumber.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Mohammad Mahdi Malmasi
9831139
Binary file added Mohammad Mahdi Malmasi/workshop4/.DS_Store
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"workbench.colorCustomizations": {
"activityBar.background": "#213307",
"titleBar.activeBackground": "#2E470A",
"titleBar.activeForeground": "#F5FCEB"
}
}
61 changes: 61 additions & 0 deletions Mohammad Mahdi Malmasi/workshop4/VotingSystem/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import java.util.ArrayList;



/**
* this is a test case for Main class
* and we check it manual if you want to work with the app
* please run the Run.java
*/
public class Main
{

public static void main(String[] args)
{
// create a new voting system
VotingSystem votingSystem = new VotingSystem();

// set the question
String question = "Are you good in java?";

// set the choices
ArrayList<String> choices = new ArrayList<String>();
choices.add("Yes");
choices.add("No");


// create a new voting
votingSystem.createVoting(question, 1, choices);


// show the added voting details
votingSystem.getVoting(0);




// create a voter
Person voter = new Person("Mohammad Mahdi", "Malmasi");

// create a list for voter votes
ArrayList<String> voterChoices = new ArrayList<>();

// add the voter choice
voterChoices.add("No");

// add the voter vote to the voting
votingSystem.vote(0, voter, voterChoices);



/* set another voter */

voter = new Person("Mr", "X");

// choose randomly
votingSystem.vote(0, voter, null);


votingSystem.getResult(0);
}
}
71 changes: 71 additions & 0 deletions Mohammad Mahdi Malmasi/workshop4/VotingSystem/Person.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@


/**
* This class repersent a Person.
* It holds the name of the Person
*
* @author Mohammad Mahdi Malmasi
* @version 0.1.0
*/
public class Person
{
/* Feilds */

//the first name of the person
private String firstName;

//the last name of the person
private String lastName;







/* Constructor */

/**
* Create a new Person with given name
*
* @param firstName : the first name of the person
* @param lastName : the last name of the person
*/
public Person(String firstName, String lastName)
{
this.firstName = firstName;
this.lastName = lastName;
}






/* Methods */

/**
* @return the last name of the person
*/
public String getLastName()
{
return lastName;
}
/**
* @return the first name of the perosn
*/
public String getFirstName()
{
return firstName;
}


/**
* @return a {@code String} of the player feilds
*/
@Override
public String toString()
{
return "First Name: " + this.firstName + " , Last Name: " + this.lastName;
}
}
75 changes: 75 additions & 0 deletions Mohammad Mahdi Malmasi/workshop4/VotingSystem/Vote.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@





/**
* This class repersent a vote in {@code Voting} class
*
* @author Mohammad Mahdi Malmasi
* @version 0.1.0
*/
public class Vote
{
/* Feilds */

// the Voter of this vote
private Person voter;

//The date of the Vote
private String date;







/* Constructor */

/**
* Create a new Vote
*
* @param voter : the voter
* @param date : the date of the vote
*/
public Vote(Person voter, String date)
{
this.date = date;
this.voter = voter;
}






/* Methods */

/**
* @return the voter of this vote
*/
public Person getVoter()
{
return voter;
}
/**
* @return the date of this vote
*/
public String getDate()
{
return date;
}



/**
* @return a {@code String} of the name of the voter of this vote and the date of the this vote
*/
@Override
public String toString()
{
return "Person: " + this.voter.getFirstName() + " " + this.voter.getLastName() + ", " +
"voted this vote on: " + date;
}
}
Loading