Created
March 29, 2013 16:10
-
-
Save ecmelkytz/5271800 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
#!usr/bin/ruby | |
#encoding: utf-8 | |
#Bilgisayarin urettigi sayiyi tahmin etme oyunu | |
puts "Tahmin icin 0-100 arasi bir sayi giriniz." | |
puts "Cikmak icin q ya basin" | |
tahmin_sayisi = 1 | |
s = Random.new | |
sayi = s.rand(0..100) | |
while 1 | |
puts "Bir sayi giriniz:" | |
tahmin=gets | |
if tahmin.to_i == sayi | |
puts "Tebrikler #{tahmin_sayisi} kerede sayiyi buldunuz." | |
break | |
elsif tahmin.to_i > sayi | |
puts "Buyuk bir tahmin oldu.Biraz asagiya in" | |
tahmin_sayisi += 1 | |
elsif tahmin.to_i < sayi | |
puts "Kucuk bir tahmin oldu.Biraz yukariya cik" | |
tahmin_sayisi += 1 | |
elsif tahmin == "q" | |
break | |
elsif 0 >= tahmin || 100 <= tahmin | |
puts "Girilen sayi 0-100 arasi degil.Tekrar deneyiniz" | |
tahmin_sayisi += 1 | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment