--- In [EMAIL PROTECTED], "Ron Jeffries" wrote:
 
> >     self isStrike ifTrue: [^self sumThreeBalls].
> >     self isSpare  ifTrue: [^self sumThreeBalls].
> >     ^self sumTwoBalls
> > 

I scratched it out a little and it looks nice ... I'll probably dump 
the 2-class version in favor of it, since it's back to 1 class (and 
still the same trivial problem assignment).

Looks a bit like this (pardon the forced indentation). 'frameStart' 
gets to be an inst var, everything else is pretty much self-
explanatory. I'm hoping this would show off the rules of bowling a 
little more easily.


score
 .. | score |
 .. .. score := 0.
 .. .. frameStart := 1.
 .. .. 10 timesRepeat: [  
 .. .. .. score := score + ( self scoreThisFrame ).
 .. .. .. self nextFrame.
 .. .. ].
 .. ^score

scoreFrame
 .. ^ self isStrikeOrSpareHere
 .. .. ifTrue:  [ self sumThreeRolls ]
 .. .. ifFalse: [ self sumTwoRolls ] 

nextFrame
 .. frameStart := frameStart + 
 .. .. ( self isStrikeHere 
 .. .. .. ifTrue:   [ 1 ]
 .. .. .. ifFalse: [ 2 ] )







To Post a message, send it to:   [EMAIL PROTECTED]

To Unsubscribe, send a blank message to: [EMAIL PROTECTED]

ad-free courtesy of objectmentor.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/extremeprogramming/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to