Created
August 26, 2013 15:49
-
-
Save ashleytbasinger/4f991ef463dc154b8a8a to your computer and use it in GitHub Desktop.
Card Constructor
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
class Card | |
def initialize(rank = nil, suit = nil) | |
if suit.nil? | |
@suit = ['♠', '♣', '♥', '♦'].sample | |
else | |
@suit = suit | |
end | |
@rank = [2, 3, 4, 5, 6, 7, 8, 9, 10, 'J', 'Q', 'K', 'A'].sample | |
puts "Create a new card: #{@rank} of #{@suit}" | |
end | |
end | |
Card.new |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment