Skip to content

Instantly share code, notes, and snippets.

@akcrono
Created August 28, 2014 17:27
Show Gist options
  • Save akcrono/0703af9204a18e4b2366 to your computer and use it in GitHub Desktop.
Save akcrono/0703af9204a18e4b2366 to your computer and use it in GitHub Desktop.
class Card
def initialize(rank = nil, suit = nil)
if suit.nil?
@suit = ['♠', '♣', '♥', '♦'].sample
else
@suit = suit
end
if rank.nil?
srand()
@rank = rand(13)+1
else
@rank = rank
end
puts "Create a new card: #{@rank} of #{@suit}"
end
end
5.times { Card.new() }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment