Created
August 4, 2014 00:54
-
-
Save andyweiss1982/68e3fced11025014cfca to your computer and use it in GitHub Desktop.
Election Day
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Display | |
def self.showtitle | |
puts " | |
███████╗██╗ ███████╗ ██████╗████████╗██╗ ██████╗ ███╗ ██╗ | |
██╔════╝██║ ██╔════╝██╔════╝╚══██╔══╝██║██╔═══██╗████╗ ██║ | |
█████╗ ██║ █████╗ ██║ ██║ ██║██║ ██║██╔██╗ ██║ | |
██╔══╝ ██║ ██╔══╝ ██║ ██║ ██║██║ ██║██║╚██╗██║ | |
███████╗███████╗███████╗╚██████╗ ██║ ██║╚██████╔╝██║ ╚████║ | |
╚══════╝╚══════╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ | |
██████╗ █████╗ ██╗ ██╗ | |
██╔══██╗██╔══██╗╚██╗ ██╔╝ | |
██║ ██║███████║ ╚████╔╝ | |
██║ ██║██╔══██║ ╚██╔╝ | |
██████╔╝██║ ██║ ██║ | |
╚═════╝ ╚═╝ ╚═╝ ╚═╝ | |
" | |
end | |
def self.democratswin | |
puts " | |
██████╗ ███████╗███╗ ███╗ ██████╗ ██████╗██████╗ █████╗ ████████╗███████╗ | |
██╔══██╗██╔════╝████╗ ████║██╔═══██╗██╔════╝██╔══██╗██╔══██╗╚══██╔══╝██╔════╝ | |
██║ ██║█████╗ ██╔████╔██║██║ ██║██║ ██████╔╝███████║ ██║ ███████╗ | |
██║ ██║██╔══╝ ██║╚██╔╝██║██║ ██║██║ ██╔══██╗██╔══██║ ██║ ╚════██║ | |
██████╔╝███████╗██║ ╚═╝ ██║╚██████╔╝╚██████╗██║ ██║██║ ██║ ██║ ███████║ | |
╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚══════╝ | |
██╗ ██╗██╗███╗ ██╗ | |
██║ ██║██║████╗ ██║ | |
██║ █╗ ██║██║██╔██╗ ██║ | |
██║███╗██║██║██║╚██╗██║ | |
╚███╔███╔╝██║██║ ╚████║ | |
╚══╝╚══╝ ╚═╝╚═╝ ╚═══╝ | |
" | |
end | |
def self.republicanswin | |
puts " | |
██████╗ ███████╗██████╗ ██╗ ██╗██████╗ ██╗ ██╗ ██████╗ █████╗ ███╗ ██╗███████╗ | |
██╔══██╗██╔════╝██╔══██╗██║ ██║██╔══██╗██║ ██║██╔════╝██╔══██╗████╗ ██║██╔════╝ | |
██████╔╝█████╗ ██████╔╝██║ ██║██████╔╝██║ ██║██║ ███████║██╔██╗ ██║███████╗ | |
██╔══██╗██╔══╝ ██╔═══╝ ██║ ██║██╔══██╗██║ ██║██║ ██╔══██║██║╚██╗██║╚════██║ | |
██║ ██║███████╗██║ ╚██████╔╝██████╔╝███████╗██║╚██████╗██║ ██║██║ ╚████║███████║ | |
╚═╝ ╚═╝╚══════╝╚═╝ ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═════╝╚═╝ ╚═╝╚═╝ ╚═══╝╚══════╝ | |
██╗ ██╗██╗███╗ ██╗ | |
██║ ██║██║████╗ ██║ | |
██║ █╗ ██║██║██╔██╗ ██║ | |
██║███╗██║██║██║╚██╗██║ | |
╚███╔███╔╝██║██║ ╚████║ | |
╚══╝╚══╝ ╚═╝╚═╝ ╚═══╝ | |
" | |
end | |
def self.voterapathy | |
puts " | |
██╗ ██╗██████╗█████████████████████╗ █████╗██████╗ █████╗██████████╗ ████╗ ██╗ | |
██║ ████╔═══██╚══██╔══██╔════██╔══██╗ ██╔══████╔══████╔══██╚══██╔══██║ ██╚██╗ ██╔╝ | |
██║ ████║ ██║ ██║ █████╗ ██████╔╝ █████████████╔███████║ ██║ ███████║╚████╔╝ | |
╚██╗ ██╔██║ ██║ ██║ ██╔══╝ ██╔══██╗ ██╔══████╔═══╝██╔══██║ ██║ ██╔══██║ ╚██╔╝ | |
╚████╔╝╚██████╔╝ ██║ █████████║ ██║ ██║ ████║ ██║ ██║ ██║ ██║ ██║ ██║ | |
╚═══╝ ╚═════╝ ╚═╝ ╚══════╚═╝ ╚═╝ ╚═╝ ╚═╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ | |
" | |
end | |
def self.coup | |
puts " | |
▄████▄ ▒█████ █ ██ ██▓███ ▓█████▄ ▓█████ ▄▄▄█████▓ ▄▄▄ ▄▄▄█████▓ | |
▒██▀ ▀█ ▒██▒ ██▒ ██ ▓██▒▓██░ ██▒ ▒██▀ ██▌ ▓█ ▀ ▓ ██▒ ▓▒▒████▄ ▓ ██▒ ▓▒ | |
▒▓█ ▄ ▒██░ ██▒▓██ ▒██░▓██░ ██▓▒ ░██ █▌ ▒███ ▒ ▓██░ ▒░▒██ ▀█▄ ▒ ▓██░ ▒░ | |
▒▓▓▄ ▄██▒▒██ ██░▓▓█ ░██░▒██▄█▓▒ ▒ ░▓█▄ ▌ ▒▓█ ▄ ░ ▓██▓ ░ ░██▄▄▄▄██ ░ ▓██▓ ░ | |
▒ ▓███▀ ░░ ████▓▒░▒▒█████▓ ▒██▒ ░ ░ ░▒████▓ ░▒████▒ ▒██▒ ░ ▓█ ▓██▒ ▒██▒ ░ | |
░ ░▒ ▒ ░░ ▒░▒░▒░ ░▒▓▒ ▒ ▒ ▒▓▒░ ░ ░ ▒▒▓ ▒ ░░ ▒░ ░ ▒ ░░ ▒▒ ▓▒█░ ▒ ░░ | |
░ ▒ ░ ▒ ▒░ ░░▒░ ░ ░ ░▒ ░ ░ ▒ ▒ ░ ░ ░ ░ ▒ ▒▒ ░ ░ | |
░ ░ ░ ░ ▒ ░░░ ░ ░ ░░ ░ ░ ░ ░ ░ ░ ▒ ░ | |
░ ░ ░ ░ ░ ░ ░ ░ ░ ░ | |
░ ░ | |
" | |
end | |
def self.showpolitician | |
puts " | |
, | , | |
\\ / | |
,,_--_, | |
\\./ ,// _ _\\ \\./ | |
;;\\ // x x /;;; | |
\\ \\ | _\\ / / | |
\\ \\ \\ o / / / | |
\\ `-'\\__/-' / | |
\\ \\/ / | |
| /\\ | | |
| |//|| | |
| \\/ | | |
.--'-----'-----. | |
/| | | |
/ | | | |
| | ,d888b, | | |
| | J8888888L | | |
| | 888888888 | | |
" | |
end | |
def self.showvoter | |
puts " | |
.-----------------------. | |
( Who should I vote for? ) | |
'--,--------------------' | |
.-\"\"\"\"\"-. o | |
/ _____/\_\ o | |
//`__ __ \\\\ O | |
// (o) (o) \\\\ | |
(_ (___) _) | |
\\ _____ / | |
`-._ _.-' | |
__.-)_(-,__ | |
./'/ |_| \\`\\. | |
/ `\"\"\"\"\"\"\"\"\"\"` \\ | |
" | |
end | |
def self.showmap | |
puts " | |
,__ _, | |
\\~\\| ~~---___ , | \\ | |
| / | ~~~~~~~|~~~~~| ~~---, _/, > | |
/~-_--__| | | \\ / ~\\~~/ /~| ||,' | |
| / \\ |------| { / /~) __- ',|_\\, | |
/ | |~~~~~~~~| \\ \\ | | '~\\ |_____,|~,-' | |
|~~--__ | | |____ |~~~~~|--| |__ /_-' {,~ | |
| | ~~~|~~| | ~~\\ / `-' |`~ |~_____{/ | |
| | | '---------, \\----| | | ,' ~/~\\,|` | |
', \\ | | |~~~~~~~| \\ | ,'~~\\ / | | |
| \\ | | | | \\_-~ /`~___--\\ | |
', \\ ,-----|-------+-------'_____/__----~~/ / | |
'_ '\\| | |~~~| | | _/-,~~-,/ | |
\\ | | | |_ | /~~|~~\\ \\,/ | |
~~~-' | | `~~~\\___| | | / | |
'-,_ | _____| | / | ,-'---~\\ | |
`~'~ \\ | `--,~~~~-~~, \\ | |
\\/~\\ /~~~`---` | \\ | |
\\ / \\ | | |
\\ | '\\' | |
`~' " | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "./ElectionDisplay.rb" | |
#clears the screen | |
def clearscreen | |
counter=0 | |
until counter == 50 | |
puts " " | |
counter += 1 | |
end | |
end | |
#returns the user to mainmenu when enter is pressed | |
def pressenter | |
inputok = false | |
until inputok | |
puts "Press enter to return to main menu." | |
puts "" | |
goback = gets.chomp | |
if goback == "" | |
inputok = true | |
mainmenu | |
else inputok = false | |
end | |
end | |
end | |
#mainmenu | |
def mainmenu | |
clearscreen | |
Display.showtitle | |
puts "What do you want to do?" | |
puts "" | |
puts "Create, List, Update or Vote" | |
puts "" | |
@mainmenuinput = gets.chomp.downcase.capitalize! | |
inputok = false | |
until inputok | |
case @mainmenuinput | |
when "Create", "List", "Update", "Vote" | |
inputok = true | |
mainmenulogic | |
else | |
clearscreen | |
puts "Input Invalid." | |
puts "" | |
puts "What do you want to do?" | |
puts "" | |
puts "Create, List, Update or Vote" | |
puts "" | |
@mainmenuinput = gets.chomp.downcase.capitalize! | |
end | |
end | |
end | |
#responds to mainmenu input | |
def mainmenulogic | |
case @mainmenuinput | |
when "Create" | |
askpoliorvoter | |
when "List" | |
showlist | |
when "Update" | |
updatecharacters | |
when "Vote" | |
puts checkcandidates | |
else | |
puts "WTF." | |
end | |
end | |
#does the user want to create a voter or politician? | |
def askpoliorvoter | |
clearscreen | |
puts "What would you like to create?" | |
puts "" | |
puts "Politician or Voter" | |
puts "" | |
inputok = false | |
@poliorvoter = gets.chomp.downcase.capitalize! | |
until inputok == true | |
if @poliorvoter == "Politician" | |
inputok = true | |
createpolitician | |
elsif @poliorvoter == "Voter" | |
inputok = true | |
createvoter | |
else inputok = false | |
clearscreen | |
puts "Input Invalid." | |
puts "" | |
puts "What would you like to create?" | |
puts "" | |
puts "Politician or Voter?" | |
puts "" | |
@poliorvoter = gets.chomp.downcase.capitalize! | |
end | |
end | |
end | |
#Creating a politician | |
def createpolitician | |
clearscreen | |
puts "Name?" | |
puts "" | |
@name = gets.chomp.downcase.capitalize! | |
clearscreen | |
puts "Party? Democrat or Republican" | |
puts "" | |
inputok = false | |
@party = gets.chomp.downcase.capitalize! | |
until inputok == true | |
case @party | |
when "Democrat", "Republican" | |
inputok = true | |
clearscreen | |
puts "Saving Politician:" | |
puts "" | |
puts "Name: #{@name}" | |
puts "" | |
puts "Party: #{@party}" | |
puts "" | |
Display.showpolitician | |
puts "" | |
@politicians << [@name, @party] | |
@politicians.each {|a,b| @politicianhash[a] = b} | |
pressenter | |
else inputok = false | |
clearscreen | |
puts "Input Invalid." | |
puts "" | |
puts "Party? Democrat or Republican" | |
puts "" | |
@party = gets.chomp.downcase.capitalize! | |
end | |
end | |
end | |
#creating a voter | |
def createvoter | |
clearscreen | |
puts "Name?" | |
puts "" | |
@name = gets.chomp.downcase.capitalize! | |
clearscreen | |
puts "Politics? Liberal, Conservative, Tea Party, Socialist, or Neutral" | |
puts "" | |
inputok = false | |
@politics = gets.chomp.downcase.capitalize! | |
until inputok == true | |
case @politics | |
when "Liberal", "Conservative", "Tea party", "Socialist", "Neutral" | |
inputok = true | |
clearscreen | |
puts "Saving Voter:" | |
puts "" | |
puts "Name: #{@name}" | |
puts "" | |
puts "Politics: #{@politics}" | |
puts "" | |
Display.showvoter | |
@voters << [@name, @politics] | |
@voters.each {|a,b| @voterhash[a] = b} | |
pressenter | |
else inputok = false | |
clearscreen | |
puts "Input Invalid." | |
puts "" | |
puts "Politics? Liberal, Conservative, Tea Party, Socialist, or Neutral" | |
puts "" | |
@politics = gets.chomp.downcase.capitalize! | |
end | |
end | |
end | |
#Lists the characters | |
def showlist | |
clearscreen | |
puts "Politicians:" | |
puts "" | |
@politicianhash.each {|name, party| print name + ", " + party + "\n"} | |
puts "" | |
puts "Voters:" | |
puts "" | |
@voterhash.each {|name, politics| print name + ", " + politics + "\n"} | |
puts "" | |
pressenter | |
end | |
#Update the Characters | |
def updatecharacters | |
clearscreen | |
puts "Name?" | |
puts "" | |
@persontoupdate = gets.chomp.downcase.capitalize! | |
#updated a voter | |
if @voterhash.include?(@persontoupdate) | |
puts "" | |
puts "New Name?" | |
puts "" | |
@newname = gets.chomp.downcase.capitalize! | |
puts "" | |
puts "New Politics?" | |
puts "" | |
inputok = false | |
@newpolitics = gets.chomp.downcase.capitalize! | |
until inputok == true | |
case @newpolitics | |
when "Liberal", "Conservative", "Tea party", "Socialist", "Neutral" | |
inputok = true | |
else inputok = false | |
clearscreen | |
puts "Input Invalid." | |
puts "" | |
puts "New Politics? Liberal", "Conservative", "Tea party", "Socialist", "Neutral" | |
puts "" | |
@newpolitics = gets.chomp.downcase.capitalize! | |
end | |
end | |
@voterhash.delete(@persontoupdate) | |
@newvoterhash = {@newname => @newpolitics} | |
@voterhash.merge!(@newvoterhash) | |
clearscreen | |
puts "Updating Voter: #{@persontoupdate}" | |
puts "" | |
puts "New Name: #{@newname}" | |
puts "" | |
puts "New Politics: #{@newpolitics}" | |
puts "" | |
Display.showvoter | |
puts "" | |
pressenter | |
#updating a politician | |
elsif @politicianhash.include?(@persontoupdate) | |
puts "" | |
puts "New Name?" | |
puts "" | |
@newname = gets.chomp.downcase.capitalize! | |
puts "" | |
puts "New Party? Democrat or Republican" | |
puts "" | |
inputok = false | |
@newparty = gets.chomp.downcase.capitalize! | |
until inputok == true | |
case @newparty | |
when "Republican", "Democrat" | |
inputok = true | |
else inputok = false | |
clearscreen | |
puts "Input Invalid." | |
puts "" | |
puts "New Party? Democrat or Republican" | |
puts "" | |
@newparty = gets.chomp.downcase.capitalize! | |
end | |
end | |
@politicianhash.delete(@persontoupdate) | |
@newpoliticianhash = {@newname => @newparty} | |
@politicianhash.merge!(@newpoliticianhash) | |
clearscreen | |
puts "Updating Politician: #{@persontoupdate}" | |
puts "" | |
puts "New Name: #{@newname}" | |
puts "" | |
puts "New Party: #{@newparty}" | |
puts "" | |
Display.showpolitician | |
puts "" | |
pressenter | |
else puts "" | |
puts "That person isn't on the voting rolls or candidate list." | |
puts "" | |
pressenter | |
end | |
end | |
#verifies there are enough candidates to run an election | |
def checkcandidates | |
clearscreen | |
@democrathash = @politicianhash.select {|name, party| party == "Democrat"} | |
@democratarray = @democrathash.keys | |
@republicanhash = @politicianhash.select {|name, party| party == "Republican"} | |
@republicanarray = @republicanhash.keys | |
puts "The parties are picking their nominees in a smoky back room." | |
puts "" | |
puts "Democratic Candidates:" | |
puts "" | |
@democratarray.each {|name| puts name} | |
puts "" | |
puts "Republican Candidates:" | |
puts "" | |
@republicanarray.each {|name| puts name} | |
sleep 3 | |
clearscreen | |
if @democratarray.length >= 1 | |
@democraticnominee = @democratarray.sample | |
puts "The winner of the Democratic Primary is #{@democraticnominee}." | |
puts "" | |
@demprimary = true | |
sleep 3 | |
else puts "The Democrats couldn't field a candidate." | |
puts "" | |
@demprimary = false | |
sleep 3 | |
end | |
if @republicanarray.length >= 1 | |
@republicannominee = @republicanarray.sample | |
puts "The winner of the Republian Primary is #{@republicannominee}." | |
puts "" | |
@repprimary = true | |
sleep 3 | |
else puts "The Republicans couldn't field a candidate." | |
puts "" | |
@repprimary = false | |
sleep 3 | |
end | |
if @demprimary != true and @repprimary != true | |
puts "There aren't any candidates. Create some politicians." | |
puts "" | |
pressenter | |
elsif @repprimary == true and @demprimary == false | |
puts "The winner by default is #{@republicannominee}." | |
puts "" | |
Display.republicanswin | |
puts "" | |
@politicianhash.clear | |
@voterhash.clear | |
pressenter | |
elsif @repprimary == false and @demprimary == true | |
puts "The winner by default is #{@democraticnominee}." | |
puts "" | |
Display.democratswin | |
puts "" | |
@politicianhash.clear | |
@voterhash.clear | |
pressenter | |
elsif @repprimary == true and @demprimary == true | |
puts "Now for the general election." | |
puts "" | |
sleep 3 | |
voterscheck | |
else puts "WTF" | |
end | |
end | |
#verifies there are voters | |
def voterscheck | |
clearscreen | |
if @voterhash.length <1 | |
@randomvictor = [@democraticnominee, @republicannominee].sample | |
puts "There aren't any voters. The democratic order faulters." | |
sleep 2 | |
puts "" | |
puts "#{@randomvictor} seizes power in a bloody coup d'etat." | |
puts "" | |
Display.voterapathy | |
sleep 2 | |
Display.coup | |
puts "Go ahead and create some voters." | |
puts "" | |
pressenter | |
else | |
displayvoters | |
end | |
end | |
#shows the voter rolls and candidate lists before the general election | |
def displayvoters | |
clearscreen | |
puts "Democratic Candidate: #{@democraticnominee}" | |
puts "" | |
puts "Republican Candidate: #{@republicannominee}" | |
puts "" | |
puts "Voters:" | |
puts "" | |
puts "" | |
@voterhash.each {|name, politics| print name + ", " + politics + "\n"} | |
puts "" | |
sleep 5 | |
demstumpspeech | |
end | |
#democratic stump speech | |
def demstumpspeech | |
clearscreen | |
puts "First, #{@democraticnominee} will make a stump speech." | |
puts "" | |
Display.showpolitician | |
sleep 2 | |
puts "" | |
puts "I, #{@democraticnominee}, promise more investment in education and infrastructure," | |
puts "" | |
sleep 2 | |
puts "a more modest foreign policy, and a more just social order." | |
sleep 2 | |
puts "" | |
puts "I promise, if you vote for me, you won't regret it." | |
sleep 2 | |
clearscreen | |
puts "Let's poll the people." | |
sleep 2 | |
pollthepeople1 | |
end | |
#converts the voter and politican hashes to numbers to do math on | |
def politicstonumbers | |
@voternumberhash = {} | |
@voterhash.each {|name, politics| | |
case politics | |
when "Socialist" | |
politics = 90 | |
when "Liberal" | |
politics = 70 | |
when "Neutral" | |
politics = 50 | |
when "Conservative" | |
politics = 30 | |
when "Tea party" | |
politics = 10 | |
else politics = "WTF" | |
end | |
@voternumberhash[name] = politics} | |
@politiciannumberhash = {@democraticnominee => 100, @republicannominee => 0} | |
@voternumberhash.merge!(@politiciannumberhash) | |
end | |
#characters comment on stump speech | |
def pollthepeople1 | |
clearscreen | |
politicstonumbers | |
@voternumberhash.each {|name, politics| | |
if (politics == 0) | |
puts "#{name} says..." | |
sleep 1 | |
puts "" | |
puts "Get your facts straight, #{@democraticnominee}. My stump speech will be way better." | |
puts "" | |
sleep 3 | |
elsif (politics == 100) | |
puts "#{name} says..." | |
sleep 1 | |
puts "" | |
puts "Duh, obviously I'm voting for myself." | |
puts "" | |
sleep 3 | |
elsif (politics >= rand(100)) | |
puts "#{name} says..." | |
sleep 1 | |
puts "" | |
puts "'What fine political oratory. I think I will vote Democrat.'" | |
puts "" | |
sleep 1 | |
elsif (politics <= rand(100)) | |
puts "#{name} says..." | |
sleep 1 | |
puts "" | |
puts "'What a load of crap. I'm voting Republican.'" | |
puts "" | |
sleep 1 | |
end} | |
repstumpspeech | |
end | |
#republican stump speech | |
def repstumpspeech | |
clearscreen | |
puts "Now, #{@republicannominee} will make a stump speech." | |
puts "" | |
Display.showpolitician | |
sleep 2 | |
puts "I, #{@republicannominee}, promise more investment in national security," | |
puts "" | |
sleep 2 | |
puts "lower taxes for all, and a government that respects traditonal values." | |
sleep 2 | |
puts "" | |
puts "I promise, if you vote for me, you won't regret it." | |
sleep 2 | |
clearscreen | |
puts "Let's poll the people now." | |
sleep 2 | |
pollthepeople2 | |
end | |
#second opportunity for comment | |
def pollthepeople2 | |
clearscreen | |
politicstonumbers | |
@voternumberhash.each {|name, politics| | |
if (politics == 100) | |
puts "#{name} says..." | |
sleep 1 | |
puts "" | |
puts "What complete and utter nonsense, #{@republicannominee}. My stump speech was way better." | |
puts "" | |
sleep 1 | |
elsif (politics == 0) | |
puts "#{name} says..." | |
sleep 1 | |
puts "" | |
puts "Duh, obviously I'm voting for myself." | |
puts "" | |
sleep 3 | |
elsif (politics >= rand(100)) | |
puts "#{name} says..." | |
sleep 1 | |
puts "" | |
puts "'What a load of crap. I'm voting Democrat.'" | |
puts "" | |
sleep 1 | |
elsif (politics <= rand(100)) | |
puts "#{name} says..." | |
sleep 1 | |
puts "" | |
puts "'What fine political oratory. I think I will vote Republican.'" | |
puts "" | |
sleep 1 | |
end} | |
generalelection | |
end | |
#voters vote | |
def generalelection | |
clearscreen | |
politicstonumbers | |
puts "But you never know what people will do behind the curtain of the voting booth." | |
puts "" | |
Display.showmap | |
sleep 2 | |
puts "Let's wait while the votes are tallied." | |
puts "" | |
sleep 3 | |
@demtotal = 0 | |
@reptotal = 0 | |
@voternumberhash.each {|name, politics| | |
if (politics >= rand(100)) | |
@demtotal += 1 | |
sleep 1 | |
puts "Democratic votes: #{@demtotal}" | |
sleep 1 | |
elsif (politics <= rand(100)) | |
@reptotal += 1 | |
sleep 1 | |
puts "Republican votes: #{@reptotal}" | |
sleep 1 | |
end} | |
sleep 2 | |
countvotes | |
end | |
#displays results | |
def countvotes | |
clearscreen | |
puts "Final Tally:" | |
puts "" | |
sleep 2 | |
puts "#{@democraticnominee}: #{@demtotal}" | |
puts "" | |
sleep 2 | |
puts "#{@republicannominee}: #{@reptotal}" | |
puts "" | |
sleep 4 | |
if @demtotal == @reptotal | |
@randomvictor = [@democraticnominee, @republicannominee].sample | |
puts "The Supreme Court rules in favor of #{@randomvictor}." | |
puts "" | |
puts "Do you believe the election results?" | |
puts "" | |
sleep 2 | |
puts "Better check the source code..." | |
puts "" | |
@politicianhash.clear | |
@voterhash.clear | |
@politiciannumberhash.clear | |
@voternumberhash.clear | |
pressenter | |
elsif @demtotal > @reptotal | |
Display.democratswin | |
puts "" | |
puts "Do you believe the election results?" | |
puts "" | |
sleep 2 | |
puts "Better check the source code..." | |
puts "" | |
@politicianhash.clear | |
@voterhash.clear | |
@politiciannumberhash.clear | |
@voternumberhash.clear | |
pressenter | |
elsif @reptotal > @demtotal | |
Display.republicanswin | |
puts "" | |
puts "Do you believe the election results?" | |
puts "" | |
sleep 2 | |
puts "Better check the source code..." | |
puts "" | |
@politicianhash.clear | |
@voterhash.clear | |
@politiciannumberhash.clear | |
@voternumberhash.clear | |
pressenter | |
end | |
end | |
#defines election | |
class Election | |
def initialize | |
@voters = [] | |
@politicians = [] | |
@politicianhash = {} | |
@voterhash = {} | |
clearscreen | |
mainmenu | |
end | |
end | |
e = Election.new |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment