# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
-require 'election'
-require 'condorcet'
-require 'positional'
-require 'runoff'
+require 'lib/rubyvote'
def print_winner(result)
if not result.winner?
print_winner( ApprovalVote.new(vote_array).result )
end
-def runoff_test1
- puts "USING RUNOFF..."
+def irv_test1
+ puts "USING IRV..."
puts "The winner shold be: A"
vote_array = Array.new
print_winner( InstantRunoffVote.new(vote_array).result )
end
-def runoff_test2
- puts "USING RUNOFF..."
+def irv_test2
+ puts "USING IRV..."
puts "The winner shold be: D"
vote_array = Array.new
print_winner( InstantRunoffVote.new(vote_array).result )
end
-def runoff_test3
- puts "USING RUNOFF..."
+def irv_test3
+ puts "USING IRV..."
puts "The winner shold be: C"
vote_array = Array.new
print_winner( InstantRunoffVote.new(vote_array).result )
end
+def irvlogic_test1
+ puts "USING IRV LOGIC..."
+ puts "The winner shold be: B"
+
+ vote_array = Array.new
+ 42.times {vote_array << "ABCD".split("")}
+ 26.times {vote_array << "BCDA".split("")}
+ 15.times {vote_array << "CDBA".split("")}
+ 15.times {vote_array << "DCBA".split("")}
+
+ print_winner( InstantRunoffLogicVote.new(vote_array).result )
+end
+
+def range_test1
+ puts "USING RANGE..."
+ puts "The winner shold be: B"
+
+ vote_array = Array.new
+ 42.times {vote_array << {:A => 10, :B => 5, :C => 2, :D => 1}}
+ 26.times {vote_array << {:A => 1, :B => 10, :C => 5, :D => 2}}
+ 15.times {vote_array << {:A => 1, :B => 2, :C => 10, :D => 5}}
+ 17.times {vote_array << {:A => 1, :B => 2, :C => 5, :D => 10}}
+
+ print_winner( RangeVote.new(vote_array).result )
+end
+
condorcet_test1()
ssd_test1()
ssd_test2()
borda_test1()
plurality_test1()
approval_test1()
-runoff_test1()
-runoff_test2()
-runoff_test3()
+irv_test1()
+irv_test2()
+irv_test3()
+irvlogic_test1()
+range_test1()