Created
June 7, 2012 01:37
-
-
Save ddd1600/2885997 to your computer and use it in GitHub Desktop.
rock paper scissors hw
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
class RockPaperScissors | |
HAND = { :rock => 1, :paper => 3, :scissors => 4 } | |
def play(param1, param2) | |
determinant = HAND[param1] + HAND[param2] | |
if(determinant==2) | |
puts "tie" | |
elsif(determinant==4) | |
puts "paper" | |
elsif(determinant==5) | |
puts "rock" | |
elsif(determinant==6) | |
puts "tie" | |
elsif(determinant==7) | |
puts "scissors" | |
elsif(determinant==8) | |
puts "tie" | |
else | |
puts "invalid parameters" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment