I am a newbie to Ruby and I am trying to write a coin tossing program.
It should ask how many times the coin should be flipped and output the results showing the number of times heads and tails each came up.
I got it started, but my code doesn't seem to be running and I don't know why.
class myCoin
def self.coinFlip = rand(2) + 1
puts message
userNum = gets.to_i
if coinFlip == 2
puts "Heads"else
puts "Tails"
end
end
end
begin
puts "How many times do you want to flip the coin? "
userNum = gets.to_i
userNum.times do
myCoin.new.coinFlip
end
end