
Take care to avoid compro-
mising the encapsulation
of your linked list.Do not
return an object reference
to an item still on the list.
Return a reference to a
copy of that item.
SOFTWARE
ENGINEERING TIP
1030 CHAPTER 14 An Introduction to Data Structures
The peek method is coded at lines 59–80. We traverse the list in the same
way as the delete method, except that because we will not delete a node, we
do not need to mark the node before current.
If we do not find a node containing a Player whose id is searchID, we throw
an exception at lines 74–75. If we find one, we return a copy of the Player
object contained in that node at line 78 so that we do not br ...