From: Alex Gutteridge Date: 2007-10-02T15:36:39+09:00 Subject: Re: instance variable/ I'm lost OK, final post. Here is a version using a class and instance variables: class Test def initialize @correct = 0 @total = 0 end def pose_multiplication_problem @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 += 1 else puts "Sorry, you fail" end end def score "#{@correct}/#{@total}" end end puts 'How many problems do you want to solve?' this_many = gets.chomp.to_i test = Test.new this_many.times{ test.pose_multiplication_problem } puts "You scored #{test.score}" Alex Gutteridge Bioinformatics Center Kyoto University