
Object subclass: #CardHand
  instanceVariableNames: 
    'theCards theName '
  classVariableNames: ''
  poolDictionaries: ''  !


!CardHand class methods !

newHand: aName
        "Returns a new Hand"
    | init |
    init := CardHand new.
    init aNewHandIsCreated: aName.
^init! !



!CardHand methods !
  
aNewHandIsCreated: name
        "Fixar Collectionen"
    |  |
   theCards := OrderedCollection new: 52.
   theName := name.!

printCardHand: aStream
        "Prints a hand"
    |  |
    aStream cr.
    theName printOn: aStream.
    aStream cr.
    #Spades: printOn: aStream.
     theCards do: [:kort|     aStream space.
                                        kort suit = 'S'
                                        ifTrue: [
                                        kort rank printOn: aStream.] ].
     aStream cr.
     #Hearts: printOn: aStream.
     theCards do: [:kort|     aStream space.
                                        kort suit = 'H'
                                        ifTrue: [
                                        kort rank printOn: aStream.] ].
    aStream cr.
    #Diamonds: printOn: aStream.
     theCards do: [:kort|     aStream space.
                                        kort suit = 'D'
                                        ifTrue: [
                                        kort rank printOn: aStream.] ].
     aStream cr.
     #Clubs: printOn: aStream.
     theCards do: [:kort|     aStream space.
                                        kort suit = 'C'
                                        ifTrue: [
                                        kort rank printOn: aStream.] ].
    aStream cr.!

take: aDeck
        "Takes a Card from aDeck"
    | card |
    card := aDeck next.
    theCards add: card.! !
