require "coin_toss/version" module CoinToss system ('clear') def toss (a) x = ["TAILS", "HEADS"] y = x.sample puts "It's....." sleep(2) puts y if y == "TAILS" a = a + 1 else a = a - 1 end a end def win (a) if a > 0 puts 'Player 1 wins' elsif a < 0 puts 'Player 2 wins' end end puts "Best of how many games do you want to Play? Press 1 for 1 game Press 2 for best of 3 games Press 3 for best of 5 games" k = gets.to_i system ('clear') puts 'Player 1 -- TAILS Player 2 -- HEADS' a = 0 if k == 1 b = toss 0 win b elsif k == 2 b = toss 0 c = toss b d = toss c e = b + c + d win e elsif k == 3 b = toss 0 c = toss b d = toss c e = toss d f = toss e g = b + c + d + e + f win g else puts 'invalid input' end end