Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Jeff Higgins Newsgroups: comp.lang.java.programmer Subject: Re: Help with Deck of cards assignment and getting it to deal... Date: Sun, 03 Aug 2014 17:37:18 -0400 Organization: A noiseless patient Spider Lines: 62 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 3 Aug 2014 21:37:22 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="b896cb427f8c4d19d14880347aa9d6ce"; logging-data="17696"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/5zjfv7MmrP96VdI2md8FMHhB17mQXCQA=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.6.0 In-Reply-To: Cancel-Lock: sha1:4gpu3GrVTTCqmJ8HWEbiKXrjs3s= Xref: csiph.com comp.lang.java.programmer:29543 On 08/03/2014 05:05 PM, Eric Sosman wrote: > On 8/3/2014 4:01 PM, Jeff Higgins wrote: >> On 08/03/2014 03:45 PM, Jeff Higgins wrote: >>> On 08/03/2014 03:00 PM, Eric Sosman wrote: >>>> Given the variety of card games, Comparable is a wrong-headed >>>> approach for ranks, for suits, and even for hands. >>>> >>> Perhaps, but just for my own enlightenment, allow me one more interface >>> and then describe a *simple* game that that cannot be implemented given >>> the provided interfaces. >>> >>> package scratch; >>> >>> import java.util.Collection; >>> >>> /** >>> * A Card game controller. >>> * While we have hands to play, compare hands. >>> * >>> * @author jeff >>> * >>> */ >>> public interface Ruler extends Iterable, >>> Comparable> { >>> >>> } >>> >>> >> Well, that could probably have been done better but you get my drift. > > I think so. However, I've already mentioned the "high-low" types > of Poker, where a single hand can be both higher and lower than another. > I gave one example upthread; here's another: > > With Aces high, A A A 7 7 is a "full house," a very strong hand. > It is just a little bit stronger than K K K J J, another full house, > because when two full houses meet they are ranked by their triples: > In this case, AAA beats KKK so the first hand is higher. But play > the Aces low instead, and now KKK beats AAA so the second hand is > higher. If the deal's final showdown involved these two hands, the > first could be *both* high and low, and win the entire pot by > trapping the second hand "in between." > > Your challenge, then, should you choose to accept it: Write a > compareTo() method for which AAA77.compareTo(KKKJJ) returns a > value that is simultaneously positive and negative. Maybe when > quantum computing comes of age ... I've not written an interface that compares Collections of Ranks or Suits or Cards or Decks. A Game will require such behavior. I still believe that behavior is implementable using the interfaces I've described, and not uncleanly. Please describe a *simple* situation that disproves my belief, I promise not to exercise my Weasel options. > Yes, okay, I see your "*simple*" -- but I reject it as weasel- > wording: Confronted with a game for which your approach won't work, > you could just say "Oh, but that's not *simple* in the way I choose > to define it." Problem-avoidance is a viable strategy sometimes, but > it shouldn't be mistaken for problem-solving. >