Created
June 3, 2016 23:29
-
-
Save ahmgeek/93925ccf8ab195d0e50515f3db2c07d0 to your computer and use it in GitHub Desktop.
Code CracklePop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Divisable | |
def divided_by?(num, divisor) | |
num % divisor == 0 | |
end | |
end | |
class CracklePop | |
include Divisable | |
def initialize | |
@num = (1..100).to_a | |
end | |
def execute | |
@num.each do |n| | |
puts "Crackle" if divided_by?(n, 3) | |
puts "Pop" if divided_by?(n, 5) | |
puts "CracklePop" if divided_by?(n, 5) && divided_by?(n, 3) | |
puts n | |
end | |
end | |
end | |
cp = CracklePop.new | |
cp.execute |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment