<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Aug 21, 2008, at 5:30 PM, <a href="mailto:Tcykgreis@aol.com">Tcykgreis@aol.com</a> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"> <div id="role_body" style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Arial" bottommargin="7" leftmargin="7" topmargin="7" rightmargin="7"><font id="role_document" face="Arial" color="#000000" size="2"> <div>I try to initialize by filling a byteArray with 52 numbers, 0 through 51. I tended to create additional methods to shuffle and deal the cards to four more byte arrays named north, east, south, and west. Eventually I will need another method to "stack the deck." I will also need a counter to keep track of the deal number.</div></font></div></blockquote></div><br><div>Fundamentally, I would say you are working at too low of a level. &nbsp;Using numbers to represent cards is an implementation detail you used in your previous implementations, but in Smalltalk we work at a higher level.</div><div><br></div><div>A deck, hand, pile, all can be implemented as just an OrderedCollection. &nbsp;You might start with a Deal or BridgeRound or something. &nbsp;It might have some methods like:</div><div><br></div><div><div>initialize</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>| hands deck |</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>deck := Card bridgeDeck shuffled asOrderedCollection. "just like english"</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>north := OrderedCollection new.</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>south := OrderedCollection new.</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>east := OrderedCollection new.</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>west := OrderedCollection new.</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>trick := OrderedCollection new.</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>"deal the whole deck"<br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>hands := (Array with: north with: east with: south with: west).</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>[deck isEmpty] whileFalse: &nbsp;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>[hands do: [:hand | deck ifNotEmptyDo: [:d | hand add: d removeFirst]]].</div></div><div><br></div><div>which sets up all the collections of cards in a typical bridge deal. &nbsp;trick is the middle pile in the table. &nbsp;Maybe you need it, maybe not.</div><div><br></div><div>Card is an object that contains your numerical value and has some methods that return the suit and rank. &nbsp;A class method could return an array of 52. &nbsp;</div><div><br></div><div><div>bridgeDeck</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>^(Interval from: 0 to: 51) collect: [:i | self code: i]</div></div><div><br></div><div><div>code: aNumber</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>^self new code: aNumber</div><div><br></div><div>some useful instance methods on card might be</div><div><br></div><div><div>rank</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>^(code // 4) + 1</div><div><br></div><div><div>suit</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>^(code \\ 4) + 1</div><div><br></div><div><div>printOn: aStream</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>| ranks suits |&nbsp;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>ranks := #( Ace 2 3 4 5 6 7 8 9 10 Jack Queen King ).</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>suits := #( Clubs Hearts Diamonds Spades ).</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>aStream&nbsp;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>nextPutAll: (ranks at: self rank) asString;&nbsp;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>nextPutAll: ' of ';</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>nextPutAll: (suits at: self suit) asString.</div><div><br></div><div>which will cause each card to be displayed in the form 'Ace of Clubs' or whatever.</div><div><br></div><div>Down the road, maybe you want to keep more information about players, like what tricks they've taken, so replace the OrderedCollections with a BridgePlayer with more instance variables etc...</div><div><br></div><div>Hopefully that will get you going.</div><div><br></div><div>-Todd Blanchard</div></div></div></div></div></body></html>