Last active
August 29, 2015 14:05
-
-
Save alacritythief/4b52c9726f6be831adaf to your computer and use it in GitHub Desktop.
An invocation to Card.new should result in a random card.
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 Card | |
def initialize(rank = nil, suit = nil) | |
if suit.nil? | |
@suit = ['♠', '♣', '♥', '♦'].sample | |
else | |
@suit = suit | |
end | |
if rank.nil? | |
@rank = ((2..10).to_a + ["A", "J", "Q", "K"]).sample | |
else | |
@rank = rank | |
end | |
puts "Create a new card: #{@rank} of #{@suit}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment