Getting input

I have been trying to get find a way to get input from the user, and be
able to store in a variable using shoes GUI, but i can't quite figure it
out? Does any one know how to? I know you can *replace* but that not
working for what im trying to do... if ur wondering, heres the program
that im trying to put a GUI on..
  @correct = 0
  @total = 0
   def pose_multiplication_problem
    @total = @total + 1
     multiple2 = rand(11)
     multiple1 = rand(11)
     answer = multiple1 * multiple2
     puts "What is #{multiple1} * #{multiple2} ?"
     answerp = gets.chomp.to_i
     if answer == answerp
       puts "Good job"
        @correct = @correct + 1
     else
       puts 'Sorry, you fail, correct answer is ' + answer.to_s
     end
   end
  puts 'How many problems do you want to solve?'
  this_many = gets.chomp.to_i
  oldtime = Time.now
this_many.times do
   pose_multiplication_problem
end
puts @correct.to_s + '/' + @total.to_s + 'correct'

···

--
Posted via http://www.ruby-forum.com/.

Erik Boling wrote:

I have been trying to get find a way to get input from the user, and be
able to store in a variable using shoes GUI, but i can't quite figure it
out? Does any one know how to? I know you can *replace* but that not
working for what im trying to do... if ur wondering, heres the program
that im trying to put a GUI on..
  @correct = 0
  @total = 0
   def pose_multiplication_problem
    @total = @total + 1
     multiple2 = rand(11)
     multiple1 = rand(11)
     answer = multiple1 * multiple2
     puts "What is #{multiple1} * #{multiple2} ?"
     answerp = gets.chomp.to_i
     if answer == answerp
       puts "Good job"
        @correct = @correct + 1
     else
       puts 'Sorry, you fail, correct answer is ' + answer.to_s
     end
   end
  puts 'How many problems do you want to solve?'
  this_many = gets.chomp.to_i
  oldtime = Time.now
this_many.times do
   pose_multiplication_problem
end
puts @correct.to_s + '/' + @total.to_s + 'correct'
  

This should get you started:

Shoes.app do
        multiple2 = rand(11)
        multiple1 = rand(11)
        answer = multiple1 * multiple2
        questionbox = stack { para "What is #{multiple1} * #{multiple2} ?" }

        answerp = edit_line

        button("Submit Answer") do
                if answerp.text.to_i == answer
                        alert "Correct!"
                else
                        alert "Sorry, answer is actually #{answer}"
                end
                multiple2 = rand(11)
                multiple1 = rand(11)
                answer = multiple1 * multiple2
                questionbox.clear { para "What is #{multiple1} * #{multiple2} ?" }
        end
end

-Justin