Linked Lists Method Question (need help) [code provided]

label Programming
account_circle Unassigned
schedule 10 Days
account_balance_wallet $5

Hey guys, below is a piece of code. Underneath that is what I am trying to accomplish with my code, but am confused on what to do. Can someone please help?

public class PlayerLinkedList extends ShellLinkedList
{

  public PlayerLinkedList(  )
  {
  super( );
  }

  public void insert( Player p )
  {
  // insert as head
  PlayerNode pn = new PlayerNode( new Player(  p ) );
  pn.setNext( head );
  head = pn;
  numberOfItems++;
  }

  public Player delete( int searchID )
  throws DataStructureException
  {
  PlayerNode current = head;
  PlayerNode previous = null;
  while ( current != null
  && current.getPlayer( ).getID( ) != searchID )
  {
  previous = current;
  current = current.getNext( );
  }

  if ( current == null ) // not found
  throw new DataStructureException( searchID
  + " not found: cannot be deleted" );
  else
  {
  if ( current == head )
  head = head.getNext( );  // delete head
  else
  previous.setNext( current.getNext( ) );

  numberOfItems--;
  return current.getPlayer( );
  }
  }

 
  public Player peek( int searchID )
  throws DataStructureException
  {
  PlayerNode current = head;
  while ( current != null
  && current.getPlayer( ).getID( ) != searchID )
  {
  current = current.getNext( );
  }

  if ( current == null ) // not found
  throw new DataStructureException( searchID
  + " not found: cannot be deleted" );
  else
  {
  return current.getPlayer( );
  }
  }
}


I want to include one more method that inserts a new player in the third position of the list. Head would be the first position. If the list is empty, the method will insert the new player as the head of the list.

Can anyone please help me with this? I would really appreciate it.

Nov 30th, -0001
You should ask your programming questions at likeplum. I always get good answers there to my programming issues and questions. Especially about php, js or html questions…They have programmers online to help you asap. It's free.

https://www.likeplum.com/user/learn/programming/aid/2
Jul 2nd, 2013

Did you know? You can earn $20 for every friend you invite to Studypool!
Click here to
Refer a Friend
...
Nov 30th, -0001
...
Nov 30th, -0001
Jun 26th, 2017
check_circle
Mark as Final Answer
check_circle
Unmark as Final Answer
check_circle
Final Answer

Secure Information

Content will be erased after question is completed.

check_circle
Final Answer