-
Notifications
You must be signed in to change notification settings - Fork 0
/
Deck.rb
39 lines (33 loc) · 964 Bytes
/
Deck.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env ruby
class Deck
@cardList
@@suitList = ["Hearts", "Diamonds", "Clubs", "Spades"]
@@nameForTen = ["Jack", "Queen", "King", "Ten"]
def initialize()
createDeck()
end
def pullCard()
if getCardCount == 0
print "\nDeck out of Cards! Reshuffling Deck!\n"
createDeck()
end
randomCard = rand([email protected]())
pulledCard = @cardList.delete_at(randomCard)
return pulledCard
end
def getCardCount()
return @cardList.length()
end
def createDeck()
@cardList = []
for suit in @@suitList
for index in 1..13
if index >= 10
@cardList.push(Card.new(10, suit, @@nameForTen[index-10]))
else
@cardList.push(Card.new(index, suit))
end
end
end
end
end