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: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: Help with Deck of cards assignment and getting it to deal... Date: Sun, 03 Aug 2014 17:05:28 -0400 Organization: A noiseless patient Spider Lines: 55 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:05:29 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="bd4e1cba8d8592bec5d5ed9e4537fbfd"; logging-data="4550"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18LSW+kg41+67Tv3OhgeJ9E" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.0 In-Reply-To: Cancel-Lock: sha1:wnUT32n5ptWNQZuzhIi/Wjs9vuQ= Xref: csiph.com comp.lang.java.programmer:29541 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 ... 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. -- esosman@comcast-dot-net.invalid