Coin Tossing in Ruby

Hello everyone,

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.

Any help is appreciated. Thank you.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  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
I am afraid that you are in the wrong forum. This is for C++.
Try http://www.dreamincode.net/forums/
Thanks you.
Yeah, I was just hoping to see if someone here is good at Ruby.
Topic archived. No new replies allowed.