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

F02 Final Exam Review: Segway Palm Pilot

b) In our design, we had Map class be composed of StreetAddress and GPSCoordinate classes. Since adapters are used to enable objects with different interfaces to communicate with each other, we suggest the Adapter design pattern.

ci) errands do: [: element|gridMap highlightFor: element.].

cii)
myBag := Bag new.
errands do: [:element|myBag add: element streetname.].
myBag do: [:element|((myBag occurrencesOf: element)>1) ifTrue: [Transcript show: 'There is more than one element of name', element;cr.]].

segway a.vsd


Can you please chmod that file or whatever. Thanks!



cii)
myBag := Bag new.
errands do: [:element|myBag add: element streetname.].
(myBag asSet) do: [:element|((myBag occurrencesOf: element)>1) ifTrue: [Transcript show: 'There is more than one element of name', element;cr.]].

If you don't loop through the bag as a set, you will get the duplicates.

cii)
Another approach:
myBag := Bag new.
errands do: [:element|myBag add: element streetname.
               ((myBag occurrencesOf: (element streetname)) == 2)
                   ifTrue: [Transcript show: 'There is more than one errand on street: ',
                                             (element streetname); cr.]].




Link to this Page