Hi Michael, I think Tonys model of the game is like this:
A Player throws a hand. That can be any of "rock", "scissors", or "paper". Now someone (a Game object?) has to check if the player did not make a mistake, say by throwing a "well". The set of legal throws (in this game, anyway) is somehow defined by Tony. So the Game object checks if the throw is an element of the set of legal throws. Am I describing this correctly, Tony? Cheers Matthias On Tue, Oct 14, 2008 at 8:45 AM, Michael Haupt <[EMAIL PROTECTED]> wrote: > Hi Tony, > > On Tue, Oct 14, 2008 at 8:11 AM, Tony Giaccone <[EMAIL PROTECTED]> wrote: >> validHands := Set new. >> validHands add: Rock new; add Paper new; add Scissors new. >> >> Assume I have a player object which responds to the method throwsAHand with >> an instance of Rock Paper or Scissors. >> >> how do I craft >> >> validHands contains: aPlayer throwsAHand > > 'ere, how about this: > > validHands anySatisfy: [ :elem | elem respondsTo: #throwsAHand ] > > Collection >> #anySatisfy: takes a block and evaluates it for all the > elements in the collection. It returns true if the block evaluates to > true for any of the elements, and false otherwise. > > Object >> #respondsTo: accepts a symbol (!) denoting a message name > and returns true if the object in question understands that message. > > Did I make clear what the above code does? > > Best, > > Michael > _______________________________________________ > Beginners mailing list > Beginners@lists.squeakfoundation.org > http://lists.squeakfoundation.org/mailman/listinfo/beginners > _______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners