Created
November 21, 2012 16:41
-
-
Save nfriend21/4125932 to your computer and use it in GitHub Desktop.
21
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
SUITS = %w{clubs hearts spades diamonds} | |
VALUES = ["2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"] | |
AMOUNTS = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] | |
Card = Struct.new(:value, :suit, :amount) | |
class Deck < Array | |
def initialize | |
SUITS.each do |suit| | |
VALUES.each_with_index do |value, index| | |
self << Card.new(value, suit, AMOUNTS[index]) | |
end | |
end | |
end | |
def shuffle | |
self.class.new | |
self.shuffle | |
self | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment