Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
labSessionFour
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
9931069
labSessionFour
Commits
024c89e3
Commit
024c89e3
authored
Apr 17, 2021
by
MostafaRahmati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Everything Is Completed
JavaDoc is next Step
parent
db5a7b37
Pipeline
#5937
canceled with stages
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
5 deletions
+65
-5
Main.java
src/Main.java
+54
-1
Voting.java
src/Voting.java
+9
-2
VotingSystem.java
src/VotingSystem.java
+2
-2
No files found.
src/Main.java
View file @
024c89e3
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
src/Voting.java
View file @
024c89e3
...
...
@@ -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
);
if
(
type
==
0
)
System
.
out
.
println
(
option
+
" : "
+
votes
.
size
());
else
{
int
size
=
votes
.
size
()-
1
;
System
.
out
.
println
(
option
+
" : "
+
size
);
}
}
}
...
...
src/VotingSystem.java
View file @
024c89e3
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment