package Ġus . s odium labs . elect or ate . plural ity Ċ Ċ import Ġcom . google . common . collect . Hash Multi set Ċ import Ġcom . google . common . collect . ImmutableList Ċ import Ġus . s odium labs . elect or ate . sim . Candidate Ċ import Ġus . s odium labs . elect or ate . sim . Elect oral System Name Ċ import Ġus . s odium labs . elect or ate . sim . Elect or ate Ċ import Ġjava . util . Optional Ċ import Ġjava . util . Random Ċ Ċ open Ġclass ĠRandom Two Party Pl ural ity ( private Ġval Ġrandom : ĠRandom ) Ġ: ĠPl ural ity () Ġ{ ĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġval ĠSYSTEM _ NAME Ġ= ĠElect oral System Name (" Pl ural ity Ġ- ĠRandom ĠTwo ĠParty ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġget System Name (): ĠElect oral System Name Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠSYSTEM _ NAME ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġelect Candidate ( elect or ate : ĠElect or ate ): ĠOptional < Candidate > Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbal lots Ġ= Ġelect or ate . poll ( V OT ING _ STR ATE GY , ĠgetRandom Candidates ( elect or ate )) ĊĠĠĠĠĠĠĠ Ġval Ġbal lot Count Ġ= ĠHash Multi set . create < Candidate >() ĊĊĠĠĠĠĠĠĠ Ġbal lots . map To ( bal lot Count ) Ġ{ Ġit . candidate Ġ} ĊĊĠĠĠĠĠĠĠ Ġreturn Ġfind First ( bal lot Count ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun ĠgetRandom Candidates ( elect or ate : ĠElect or ate ): ĠList < Candidate > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠImmutableList . of ( getRandom Candidate ( elect or ate ), ĠgetRandom Candidate ( elect or ate )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun ĠgetRandom Candidate ( elect or ate : ĠElect or ate ): ĠC andidate Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġelect or ate . candidates [ random . nextInt ( elect or ate . candidates . size )] ĊĠĠĠ Ġ} Ċ } Ċ