Skip to content

Instantly share code, notes, and snippets.

@alacritythief
Last active August 29, 2015 14:05
Show Gist options
  • Save alacritythief/4b52c9726f6be831adaf to your computer and use it in GitHub Desktop.
Save alacritythief/4b52c9726f6be831adaf to your computer and use it in GitHub Desktop.
An invocation to Card.new should result in a random card.
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