Created
April 16, 2014 15:11
-
-
Save seanrclayton/10891677 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
@player_win_count = 0 | |
@op_win_count = 0 | |
def game | |
choices = ['rock', 'paper', 'scissors' ] | |
playthrow = choices.sample | |
puts "player throws #{playthrow}" | |
opthrow = choices.sample | |
puts "oponent throws #{opthrow}" | |
if playthrow == 'rock' && opthrow == 'paper' | |
@op_win_count += 1 | |
puts "opponent wins their score is #{@op_win_count}" | |
elsif playthrow == 'paper' && opthrow == 'scissors' | |
@op_win_count += 1 | |
puts "opponent wins their score is #{@op_win_count}" | |
elsif playthrow == 'scissors' && opthrow == 'rock' | |
@op_win_count += 1 | |
puts "opponent wins their score is #{@op_win_count}" | |
elsif playthrow == opthrow | |
puts 'draw' | |
else | |
@player_win_count += 1 | |
puts "player wins their score is #{@player_win_count}" | |
end | |
throw | |
end | |
def throw | |
puts "Throw Again?" | |
answer = gets.chomp | |
if answer == "y" | |
game | |
elsif answer == "n" | |
puts "Goodbye" | |
else | |
puts "I have no idea what you said put y or n" | |
throw | |
end | |
end | |
game |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment