Skip to content

Instantly share code, notes, and snippets.

@caioertai
Created April 20, 2022 23:10
Show Gist options
  • Save caioertai/85c9f340174f1d21a94fc7797d56e265 to your computer and use it in GitHub Desktop.
Save caioertai/85c9f340174f1d21a94fc7797d56e265 to your computer and use it in GitHub Desktop.
class SlotMachine
VALUES = %w[x cherry seven bell star joker]
def initialize(slots)
@slots = slots
end
def play
@slots = [
VALUES[1..-1].sample,
VALUES[1..-1].sample,
VALUES[1..-1].sample
]
end
def score
case @slots.uniq.count
when 1
element = @slots.first
VALUES.index(element) * 10
when 2
return 0 unless @slots.include?("joker")
element = @slots.sort[1]
VALUES.index(element) * 5
when 3
0
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment