Created
July 11, 2016 15:06
-
-
Save ashlynnpai/0f2c95bb022f4a554bab900f9e32233a to your computer and use it in GitHub Desktop.
This file contains 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
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