所以我有代码:
puts 'What is your name?(Enter in field below)'
input = gets.chomp
puts 'end'
occupationslist = ['Engineer', 'Clerk', 'Doctor', 'Demolition Expert', 'Athlete', 'None',]
oclistlength = occupationslist.length
rand1 = rand(oclistlength)
occupation = ocupationslist[rand1]
def occupations
puts input
puts 'Occupation: ' + occupation
puts 'Rating: ' + rand(1-12).to_s
end
occupations
它应该显示您的姓名(您输入的)、随机职业和随机评级,但我不知道它有什么问题。这是令人满意的输出:
prints "What is your name?".
(gets user input)
prints out the input.
prints out a random 'occupation'(from the list in the array above).
prints out the 'Rating: ' - a random number from 0 to 12.