It seems to me that everything I describe in this blog turns out at least three times as complicated when I write it all down than it was when it was in my head. For this reason, I'm reluctant to say that GirlList is simple and straight forward. I mean, I think it is, but I'm afraid if I say so, I'll invoke Murphy.
Anyway....
class GirlList
def initialize
@list = Array.new
end
def add(actor)
@list.push(actor)
end
def do_shift(shift_id)
@list.each { |x|
x.do_shift(shift_id)
}
end
end
It's basically a wrapper around an array. Method to initialise the array, one to add girls, and one to evaluate each girl's performance in a shift. I changed do_turn to do_shift at this level, as mentioned earlier, and I may yet lower the granularity further. But this'll do for now.
Why not just have an array? I'm not sure I have a good reason, except that I often find it's good to have an explicit list class. It gives me room to add processing when a girl is added or removed, for instance.
mmm... looks like this one really was that simple.
No comments:
Post a Comment