Documente Academic
Documente Profesional
Documente Cultură
resultsaccordingtotheSchulzemethod.
1.Forthecodeuwillneedtousethelibraryjson.jarthathastobeputinasubfoldercalled
l i b. The f i l e j son. j ar i s t he compi l ed l i br ar y J SON f r omt he JSON.org
2.Thesourcecodewillbeinasubfoldercalledsr c andthecompiledcodeinasubfolder
calledbi n.
3.All3subfoldersshouldbeinthemainfoldercalledassi gnment - 3.
4.TheprogramshouldbenamedSchul ze.
5.Theprogramshouldbeexecutedlikethis:
j ava Schul ze exampl e_el ect i ons. j son
Theexitshouldbeofthisform:
a = 1 [ c]
b = 2 [ a, c]
c = 0 [ ]
d = 3 [ a, b, c]
Thismeansthatthecandidatedprevailstotheother3,thecandidatebprevailstotheother
2andthecandidateaprevailstotheotheroneandthecandidatecdoesntprevailto
anybody.
6.Thefilesthatwillbegiventotheprogramwillbeofthisform:
{
" candi dat es" : [
" a" , " b" , " c" , " d"
] ,
" bal l ot s" : [
[ 0, 2, 3, 1] ,
[ 0, 2, 3, 1] ,
[ 0, 2, 3, 1] ,
[ 0, 2, 3, 1] ,
[ 0, 2, 3, 1] ,
[ 0, 2, 3, 1] ,
[ 1, 0, 3, 2] ,
[ 1, 0, 3, 2] ,
[ 1, 0, 3, 2] ,
[ 1, 0, 3, 2] ,
[ 2, 3, 1, 0] ,
[ 2, 3, 1, 0] ,
[ 2, 3, 1, 0] ,
[ 3, 1, 0, 2] ,
[ 3, 1, 0, 2] ,
[ 3, 1, 0, 2] ,
[ 3, 1, 0, 2] ,
[ 3, 2, 1, 0] ,
[ 3, 2, 1, 0] ,
[ 3, 2, 1, 0] ,
[ 3, 2, 1, 0]
]
}
Thecompileofthefileswillbedonewithacommandofthisform:
j avac - cp " . : l i b/ j son. j ar " *. j ava
Li kewi se t he r un of t he pr ogr amwi l l be done wi t h t he command:
j ava - cp " . : l i b/ j son. j ar " Schul ze exampl e_el ect i ons. j son
These commands wi l l r un f r omt he f ol der sr c.
Bewar e of t he . ( Dot ) i n t he commands above cause i t i s necessar y i n
or der t o i ncl ude t he f ol der u ar e now i n t he cl asspat hs of j ava: t he
dot equal s t o t he f ol der u ar e now.
Li kewi se t he t wo dot s ( i n . . / l i b/ j son/ j ar ) equal s t o t he f at her of
t he f ol der u ar e now and ar e necessar y i n or der t o f i nd f r omt he
r unni ng f ol der sr c t he f ol der l i b.
I n t he wi ndows oper at i ng syst emt he char act er ; i s used i nst ead of
t he char act er : t o separ at e t he pat hs.
To check t he pr ogr amu can use t hese f i l es:
example_elections.json
schulze_1.json
example_elections_large.json
inthelastfiletheresultsshouldbe(withmaybeadifferentorderofnamesintheexit):