Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def match
- puts "Welcome to Rock - Paper - Scissors"
- puts "Choose your weapon: rock - paper - scissors"
- user_weapon = gets.strip.downcase
- random = rand(1..3)
- if random == 1
- computer_weapon = "rock"
- elsif random == 2
- computer_weapon = "paper"
- elsif random == 3
- computer_weapon = "scissors"
- end
- puts "\n"
- puts "The computer selected #{computer_weapon}."
- puts "\n"
- results(user_weapon, computer_weapon)
- puts "\n"
- play_again
- end
- def results(user_weapon, computer_weapon)
- if user_weapon === computer_weapon
- puts "It's a tie game!"
- elsif user_weapon === "rock" && computer_weapon === "scissors"
- puts "You win!"
- elsif user_weapon === "rock" && computer_weapon === "paper"
- puts "Meet your new master, the computer."
- elsif user_weapon === "paper" && computer_weapon === "rock"
- puts "You win!"
- elsif user_weapon === "paper" && computer_weapon === "scissors"
- puts "Meet your new master, the computer."
- elsif user_weapon === "scissors" && computer_weapon === "rock"
- puts "Meet your new master, the computer."
- elsif user_weapon === "scissors" && computer_weapon === "paper"
- puts "You win!"
- end
- end
- def play_again
- puts "Would you like to play again? y/n"
- input = gets.strip.downcase
- if input == "y"
- match
- else
- puts "Thanks for playing!"
- end
- end
- match
Add Comment
Please, Sign In to add comment