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
22bc950f
Commit
22bc950f
authored
Apr 17, 2021
by
MostafaRahmati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean Code
parent
024c89e3
Pipeline
#5938
canceled with stages
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
16 deletions
+17
-16
Main.java
src/Main.java
+9
-9
Person.java
src/Person.java
+5
-4
Voting.java
src/Voting.java
+3
-3
No files found.
src/Main.java
View file @
22bc950f
...
@@ -9,27 +9,27 @@ public class Main {
...
@@ -9,27 +9,27 @@ public class Main {
singleVoting
.
add
(
"option2"
);
singleVoting
.
add
(
"option2"
);
singleVoting
.
add
(
"option3"
);
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
person1
=
new
Person
(
"firstName1"
,
"lastName1"
);
Person
person2
=
new
Person
(
"firstName"
,
"lastName2"
);
Person
person2
=
new
Person
(
"firstName"
,
"lastName2"
);
Person
person3
=
new
Person
(
"firstName3"
,
"lastName3"
);
Person
person3
=
new
Person
(
"firstName3"
,
"lastName3"
);
Person
person4
=
new
Person
(
"firstName4"
,
"lastName4"
);
Person
person4
=
new
Person
(
"firstName4"
,
"lastName4"
);
system
.
vote
(
voting1
,
person1
,
"option1"
);
system
.
vote
(
voting1
,
person1
,
"option1"
);
system
.
vote
(
voting1
,
person2
,
"option2"
);
system
.
vote
(
voting1
,
person2
,
"option2"
);
system
.
vote
(
voting1
,
person3
,
"option3"
);
system
.
vote
(
voting1
,
person3
,
"option3"
);
system
.
vote
(
voting1
,
person4
,
"option2"
);
system
.
vote
(
voting1
,
person4
,
"option2"
);
system
.
printVotingResult
(
voting1
,
0
);
system
.
printVotingResult
(
voting1
,
0
);
ArrayList
<
String
>
multipleVoting
=
new
ArrayList
<>();
ArrayList
<
String
>
multipleVoting
=
new
ArrayList
<>();
multipleVoting
.
add
(
"option11"
);
multipleVoting
.
add
(
"option11"
);
multipleVoting
.
add
(
"option21"
);
multipleVoting
.
add
(
"option21"
);
multipleVoting
.
add
(
"option31"
);
multipleVoting
.
add
(
"option31"
);
Voting
voting2
=
system
.
createVoting
(
1
,
"Please Enter Your Choice For Multiple System"
Voting
voting2
=
system
.
createVoting
(
1
,
"Please Enter Your Choice For Multiple System"
,
multipleVoting
);
,
multipleVoting
);
ArrayList
<
String
>
person1Votes
=
new
ArrayList
<>();
ArrayList
<
String
>
person1Votes
=
new
ArrayList
<>();
person1Votes
.
add
(
"option11"
);
person1Votes
.
add
(
"option11"
);
...
@@ -52,7 +52,7 @@ public class Main {
...
@@ -52,7 +52,7 @@ public class Main {
system
.
vote
(
voting2
,
person3
,
person3Votes
);
system
.
vote
(
voting2
,
person3
,
person3Votes
);
system
.
vote
(
voting2
,
person4
,
person4Votes
);
system
.
vote
(
voting2
,
person4
,
person4Votes
);
system
.
printVotingResult
(
voting2
,
1
);
system
.
printVotingResult
(
voting2
,
1
);
}
}
}
}
\ No newline at end of file
src/Person.java
View file @
22bc950f
public
class
Person
{
public
class
Person
{
private
String
firstName
;
private
String
firstName
;
private
String
lastName
;
private
String
lastName
;
public
Person
(
String
firstName
,
String
lastName
){
this
.
firstName
=
firstName
;
public
Person
(
String
firstName
,
String
lastName
)
{
this
.
lastName
=
lastName
;
this
.
firstName
=
firstName
;
this
.
lastName
=
lastName
;
}
}
public
String
getFirstName
()
{
public
String
getFirstName
()
{
...
@@ -16,6 +17,6 @@ public class Person {
...
@@ -16,6 +17,6 @@ public class Person {
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
firstName
+
" "
+
lastName
;
return
firstName
+
" "
+
lastName
;
}
}
}
}
src/Voting.java
View file @
22bc950f
...
@@ -71,10 +71,10 @@ public class Voting {
...
@@ -71,10 +71,10 @@ public class Voting {
}
}
HashSet
<
Vote
>
votes
=
this
.
polls
.
get
(
option
);
HashSet
<
Vote
>
votes
=
this
.
polls
.
get
(
option
);
if
(
type
==
0
)
if
(
type
==
0
)
System
.
out
.
println
(
option
+
" : "
+
votes
.
size
());
System
.
out
.
println
(
option
+
" : "
+
votes
.
size
());
else
{
else
{
int
size
=
votes
.
size
()-
1
;
int
size
=
votes
.
size
()
-
1
;
System
.
out
.
println
(
option
+
" : "
+
size
);
System
.
out
.
println
(
option
+
" : "
+
size
);
}
}
...
...
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