Skip to content

Instantly share code, notes, and snippets.

@kajatiger
Created October 31, 2016 16:16
Show Gist options
  • Save kajatiger/cc729ea2d9d2cee75fb1ae7cc0e30019 to your computer and use it in GitHub Desktop.
Save kajatiger/cc729ea2d9d2cee75fb1ae7cc0e30019 to your computer and use it in GitHub Desktop.
play rock, scissors, paper against my code
puts "please type rock, scissors or paper"
player = gets.chomp
rand(1..3)
if rand(1..3) == 1
computer = "rock"
elsif rand(1..3) == 2
computer = "scissors"
else
computer = "paper"
end
def game(player, computer)
unless player == computer
if player == "rock"
if computer == "scissors"
puts "you win, cause rock beats scissors!"
elsif computer == "paper"
puts "the computer wins, cause paper beats rock"
end
elsif player == "paper"
if computer == "scissors"
puts "the computer wins, cause scissors cut the paper!"
elsif computer == "rock"
puts "you win, cause paper wrappes around the rock!"
end
elsif player == "scissors"
if computer == "rock"
puts "the computer beats your scissors with rock!"
elsif computer == "paper"
puts "you win, cause your scissors cut the paper"
end
else
puts "you probably didn't type scissors, rock or paper correctly"
end
else
puts "you both picked the same thing, play again!"
end
end
game(player, computer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment