Skip to content

Instantly share code, notes, and snippets.

@justuseapen
Created November 27, 2013 15:27
Show Gist options
  • Save justuseapen/7677557 to your computer and use it in GitHub Desktop.
Save justuseapen/7677557 to your computer and use it in GitHub Desktop.
# Implement your solution here. You may reference any additional files from here as well.
@results = []
def team_names_and_scores
puts "What was team one's name?"
team1 = gets.chomp
puts "What was team one's score?"
team1_score = gets.chomp
puts "What is team 2's name?"
team2 = gets.chomp
puts "What was team two's score?"
team2_score = gets.chomp
if team1 == team2
puts "Team names cannot be the same."
end
identify_winner(team1,team1_score,team2,team2_score)
end
def identify_winner(team1,team1_score,team2,team2_score)
if team1_score > team2_score
puts "#{team1} WINS!"
@results << "#{team1} is the victor!"
elsif team2_score > team1_score
puts "#{team2} WINS!"
@results << "#{team2} is the victor!"
else
puts "ITS A TIE! YOU BOTH SUCK!"
end
new_game
end
def new_game
puts "Would you like to enter another game?(Y/N)"
new_game = gets.chomp
if new_game == "Y"
team_names_and_scores
new_game
else
@results.each_with_index do |game_results, index|
puts "In game #{index+1} #{game_results}"
end
abort
end
end
team_names_and_scores
new_game
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment