Created
August 10, 2012 14:51
-
-
Save yawboakye/3314760 to your computer and use it in GitHub Desktop.
A win for @abocco in the GYAC
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 GhanaYouthAwardsCeremony | |
extend self | |
def notify_aboccos_boys | |
(@candidates.values.max + 10).times { vote_for :abocco } | |
end | |
private :notify_aboccos_boys | |
def vote_for candidate | |
@candidates ||= Hash.new 0 | |
if @candidates.has_key? candidate | |
@candidates[candidate] += 1 | |
else | |
@candidates[candidate] = 1 | |
end | |
# notify Abboco's boys that someone just voted so they should do something about it.. | |
# Don't blame me, I'm not evil. I'm just helping | |
notify_aboccos_boys unless candidate == :abocco | |
end | |
def display_results | |
@candidates.each { | |
|candidate, votes| | |
puts "#{candidate} received #{votes} vote(s)" | |
} | |
end | |
end | |
# As a good citizen, I cast just one vote | |
GhanaYouthAwardsCeremony.vote_for :abocco | |
# and wait for everybody to vote for their candidates | |
# | |
# | |
# | |
# | |
# and then display the results.. If you could read the code above | |
# you understand what will happen. Good news!! | |
GhanaYouthAwardsCeremony.display_results |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What do you say? e-Voting starts like this