#Charles Kuehne 5/2/2013
# fortune telling program
# takes user name as command line arg
# asks user to pick a sign
# uses date and sign to generate a fortune
#fortunes read from file
# responds to screen with personalized fortune
require 'date'
name = ARGV.shift #removes the argument so gets works
zod = [ "Aries", "Tarus", "Gemini", "Cancer", "Leo", "Virgo", "Libra", "Scorpio", "Sagittarious", "Capricorn", "Aquarius", "Pisces"]
alltxt = File.read("lorem.txt")# my lorem ipsum file
fortunes = alltxt.split(". ")#puts each sentance into an array
puts "Hello #{name}"
puts "please choose your sign:"
count = 0
zod.each_with_index do |sign, index| #WITH INDEX!! so sexy!
puts "(" + index.to_s + ") " + sign
end
choice = gets.to_i
while zod[choice] == nil do
puts "bad number, try again >"
choice = gets.to_i
end
puts "You chose " + choice.to_s+" which is "+ zod[choice]
today = Date.today.yday()#converts day of year to int
puts fortunes[((today * (choice+1)) % fortunes.length)]
No comments:
Post a Comment