View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

Question 1(Code)

grandChildren := OrderedCollection new.
p children do: [:child | grandChildren addAll: child children].
names := OrderedCollection 
                 with: ((grandChildren select: [:g | g isFemale]) collect: [:f | f firstName]) 
                 with: ((grandChildren reject: [:g | g isFemale]) collect: [:m | m firstName]) 

8 points for creating the collection of grandchildren
6 points for creating the two collections of first names
2 points for creating the two element collection
2 "style points" for no explicit loops (only implicit ones resulting from messages to collections)
2 "style points" for avoiding ifs by using the collection operation

Link to this Page