Created
August 28, 2014 17:27
-
-
Save akcrono/0703af9204a18e4b2366 to your computer and use it in GitHub Desktop.
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? | |
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