Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007
Q2 question and answer
Quiz # 2 — CS2340 Fall02
In your genealogy system, let’s presume that you have chosen to store all of the children of a person as a collection of Person objects in an instance variable named children. This collection can be accessed by sending a Person instance a message by the same name. Write workspace code that will print out to the Transcript the first and last names of all of the female grandchildren
You must use collect:,select:, reject:, or do: at least once in your solution. An excellent solution will make use of more than one such message.
grandChildren := OrderedCollection new.
p children do: [:child | grandChildren addAll: child children].
(grandChildren select: [:g | g isFemale]) do: …
“add code to write to Transcript here”
Link to this Page