Hello,
there is one thing that I don't like in yours and Ron's code: all
those reference to frameStart, frameStart + 1, frameStart + 2.

We are dealing with a stream of rolls, then why don't we make our data
structure a stream of rolls?

On Mon, 27 Dec 2004 07:39:16 -0000, aacockburn <[EMAIL PROTECTED]> wrote:

> Game>>framesFromRolls: rolls
>   | frameStart |
>   frames := OrderedCollection new.
>   frameStart := 1.
>   10 timesRepeat: [  | frame |
>     frame := Frame new fromRolls: rolls at: frameStart.
>     frames addLast: frame.
>     frameStart := frameStart + frame rollsUsed.
>   ].
>   ^frames
> 

Game>>framesFromRolls: rolls
  | frameStart rollsStream |
  frames := OrderedCollection new.
  rollsStream := rolls readStream.
  10 timesRepeat: [  | frame |
    frame := Frame new fromRollsStream: rollsStream.
    frames addLast: frame.
  ].
  ^frames

Frame>>fromRollsStream: rollsStream
   roll1 := rollsStream next.
   roll2 := rollsStream next.
   self isSpareOrStrike
     ifTrue: [ bonusRoll := rollsStream next ].
         ^ self
 
-- 
Roberto Lupi
http://www.lupi-software.com/


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