Skip to content

Commit

Permalink
fix one line in blackjack
Browse files Browse the repository at this point in the history
  • Loading branch information
blepati committed Apr 18, 2017
1 parent 3b016ca commit ef83c5a
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions blackjack/black_jack.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,32 @@ def __init__(self):
def create_one_card(self):
card = random.sample(self.color, 1) + random.sample(self.value, 1)
return card

def draw_one_card(self):
card = self.create_one_card()
print(card[0] +" " + card[1])

class Deck(object):
def __init__(self):
def __init__(self, num_of_cards):
self.list_of_cards = []
num_of_cards = 0
self.num_of_cards = num_of_cards
self.cards = Card()

cards = Card()
cards.draw_one_card()
#deck = Deck(12)
#print(deck)
def create_deck(self):

This comment has been minimized.

Copy link
@gygabor

gygabor Apr 18, 2017

This method should call in the constructor, and before the append it should check if the created card is unique it doesn't exists in the deck.

for card in range(self.num_of_cards):
self.list_of_cards.append(self.cards.create_one_card())

def shuffle_deck(self):

This comment has been minimized.

Copy link
@gygabor

gygabor Apr 18, 2017

👍

shuffled_deck = random.shuffle(self.list_of_cards)
return shuffled_deck

#cards = Card()
#cards.draw_one_card()
deck = Deck(12)
deck.create_deck()
print(deck.list_of_cards)
deck.shuffle_deck()
print(deck.list_of_cards)
# Should print out:
# 12 cards - 3 Clubs, 3 Diamonds, 3 Hearts, 3 Spades
#top_card = deck.draw()
Expand Down

0 comments on commit ef83c5a

Please sign in to comment.