Created
October 13, 2015 17:23
-
-
Save volpeo/270fab61ba66605def66 to your computer and use it in GitHub Desktop.
Juste Price
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
def rand_price | |
price = (1..100).to_a.sample | |
return price | |
end | |
price = rand_price | |
puts "How many players ?" | |
player_numbers = gets.chomp.to_i | |
n = 1 | |
puts "What's the price of this product ?" | |
puts "Player #{n}, your turn" | |
your_price = gets.chomp.to_i | |
until your_price == price | |
if your_price > price | |
puts "It's less" | |
elsif your_price < price | |
puts "It's more !" | |
end | |
n = n + 1 | |
if n > player_numbers | |
n = 1 | |
end | |
puts "Player #{n}, your turn" | |
your_price = gets.chomp.to_i | |
end | |
puts "You won player #{n}!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment