
1066 CHAPTER 14 An Introduction to Data Structures
40 }
41 numberOfItems++;
42 }
43
44 /** delete method
45 * @param searchID id of Player to delete
46 * @return the Player deleted
47 */
48 public Player delete( int searchID )
49 throws DataStructureException
50 {
51 PlayerNode current = head;
52 PlayerNode previous = null;
53 while ( current != null
54 && current.getPlayer().getID()!= searchID )
55 {
56 if ((current.getPlayer()).getID()> searchID )
57 throw new DataStructureException
58 ( searchID + “ not found: cannot be deleted” );
59 previous = current;
60 current = current.getNext();
61 }
62
63 if ( current == null ) // not found
64 throw new DataStructureException ...