Here I have tried a bit.

class Constlottery
    def self.rand_number
        randoms = []
        loop do
            puts "Enter a random number"
            new_number = gets.chomp
            if new_number.to_s == rand(1..9).to_s
                puts "You are winner"
                return
            else
                puts "You lost the chance"              
            end
        end
    end
end

a = Constlottery.rand_number

puts a











On Friday, September 14, 2012 7:00:40 PM UTC+5:30, Samir wrote:
>
> Can any body please help me to solve this?
>
> Create a lottery app which will take a number as parameter and there will 
> be a set of number from 0 to n random number every time. 
> If the given number matches the random array[0] number by the program, 
> show a message you won the loterry.
> If the given number matches the random array[1] number by the program, 
> show a message you are second.
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/5G5asAK5TDsJ.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to