Ruby Scripts
Μαΐου 20, 2008
Λοιπόν μπορώ να πω ότι η Ruby είναι άκρως εθιστική!!! Και ακόμα είμαι σε αρχικό στάδιο με βάση τις γνώσεις από τα tutorials!!! Εδώ μπορείτε να δείτε ένα αλλο μικρό προγραμματάκι που έκανα που συνδυάζει όλα όσα ξέρω μέχρι τώρα.
puts 'Please Enter your name...'
name = gets.chomp
puts '...and now your family name.'
fname = gets.chomp
puts 'Hello, ' + name.to_s + ' ' + fname.to_s + '. Wanna try some things? -Answer with Yes or No-'
answer1 = gets.chomp
answer1.capitalize
if answer1 == 'Yes' or 'yes' or 'y'
puts 'Okay. Let\'s continue.'
puts 'So tell me please what\'s your favorite number.'
number1 = gets.chomp
puts 'Oh, ' + number1 + ' is your fav. number.'
puts 'What about adding 1 to your selection?'
puts 'It becomes... '
puts number1.to_i + 1
puts '..right? -Answer with Yes or No'
answer2 = gets.chomp
else
puts 'Okay, no problemSee you soon!'
end
if answer2 == 'Yes' or 'yes' or 'y'
puts 'Ok... Done with that. Let\'s do and some other things'
puts name + ', please tell me your middle name now.'
mname = gets.chomp
puts 'So, ' + name + ' your full name is ' + name + ' ' + mname + ' ' + fname + '. Sounds great!'
chars = name.length + fname.length + mname.length
puts 'Now, did you know that your full name has ' + chars.to_s + ' characters?-Answer as usual with Yes or No'
answer3 = gets.chomp
answer3.capitalize
else
puts 'I can\'t be wrong!'
end
if answer3 == 'Yes' or 'yes' or 'y'
puts 'Ah, you are good... But bye for now! See you soon!'
else
puts 'Never mind! Anyway, bye for now! See you soon!'
end
puts ' '
puts 'Simple Ruby Commands by Unseen unseend.wordpress.com'
Entry Filed under: Other, Tips, Tweaks and more. Ετικέτες: programming, ruby, script.
4 Comments Add your own
Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
Trackback this post | Subscribe to the comments via RSS Feed





1.
leeturtle | Μαΐου 20, 2008 at 7:42 μμ
Re aliti, den tha itan kalutera na diavazeis gia tis eksetaseis. Tropi sou
2.
unseen | Μαΐου 20, 2008 at 8:19 μμ
χαχα! πρώτα διαβάζω μετά μεταμορφώνομαι σε geek! είναι κάτι σαν το zuperman! το πρωί δημοσιογράφος μετά super-hero… έτσι λοιπόν εγώ την μέρα μαθητής, με το που τελειώνω με τα μαθητικά πιάνομαι με τα geeky πράματα!
3.
leeturtle | Μαΐου 21, 2008 at 5:07 μμ
Re c ti skeftesai na spoudaseis?
4.
unseen | Μαΐου 21, 2008 at 5:56 μμ
κάτι σχετικό με PCs…