Skip to content

Instantly share code, notes, and snippets.

@ashlynnpai
Created July 11, 2016 15:06
Show Gist options
  • Save ashlynnpai/0f2c95bb022f4a554bab900f9e32233a to your computer and use it in GitHub Desktop.
Save ashlynnpai/0f2c95bb022f4a554bab900f9e32233a to your computer and use it in GitHub Desktop.
class Deck
attr_accessor :cards
def initialize(cards)
@cards = cards
suit = ['C', 'D', 'H', 'S']
rank = [*2..10, 'J', 'Q', 'K', 'A']
@cards = suit.product(rank).map(&:join)
end
def shuffle
@cards.shuffle!
end
def deal
@cards.shift
end
end
deck1 = Deck.new(deck1)
deck1.shuffle
p deck1
deck1.deal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment