Created
January 28, 2019 21:38
-
-
Save caioertai/8e7acd1d62e25e436094667354dceebd to your computer and use it in GitHub Desktop.
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
puts "--------------------------" | |
puts "Welcome to the horse race!" | |
puts "--------------------------" | |
horses = ['Caio Andrade', 'Eduardo', 'Marina', 'Lucas', 'Sveta'] | |
loop_input = 'y' | |
while loop_input == 'y' do | |
puts "Here are our horses:" | |
horses.each_with_index do |horse, index| | |
puts "#{index + 1}. #{horse}" | |
end | |
puts "--------------------------" | |
puts "Pick a horse to bet on:" | |
print '> ' | |
bet_index = gets.chomp.to_i - 1 | |
user_horse = horses[bet_index] | |
winner = horses.sample | |
puts "And the winner is:" | |
sleep 0.4 | |
puts "." | |
sleep 0.4 | |
puts ".." | |
sleep 0.4 | |
puts "..." | |
puts "#{winner}!!!" | |
if user_horse == winner | |
puts "Your horse won! Congrats to you and #{user_horse}!" | |
else | |
puts "#{user_horse} lost... Better luck next time!" | |
end | |
puts "-------------------------------" | |
puts "Do you want to bet again? (y/n)" | |
print '> ' | |
loop_input = gets.chomp | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment