Question: you are going to be implementing a linked list, while setting up a team roster. Most of the linked list has already been implemented, inlcluding

you are going to be implementing a linked list, while setting up a team roster. Most of the linked list has already been implemented, inlcluding a constructor and append method. You will have to implement a contains method.

you are going to be implementing a linked list, while setting up

a team roster. Most of the linked list has already been implemented,

import java.util.Scanner;

public class PoD {

public static void main( String [] args ) {

Scanner in = new Scanner( System.in );

LinkedList listOfPlayers = new LinkedList();

final int LIST_SIZE = Integer.valueOf(in.nextLine());

for (int i=0; i

listOfPlayers.append(newPlayer); }

String checkPlayerStatus = in.nextLine();

if (listOfPlayers.contains(checkPlayerStatus)) { System.out.println(checkPlayerStatus + " is on the team."); } else { System.out.println(checkPlayerStatus + " did not make the team."); }

in.close(); System.out.print("END OF OUTPUT"); }

}

---------------------------------------------------------------------------------------------------

import java.util.NoSuchElementException;

/**

* A listnked list is a sequence of nodes with efficient element

* insertion and removal. This class contains a subset of the methods

* of the standard java.util.LinkedList class.

*

* You will finish off the contains method.

*/

public class LinkedList

{

//attributes

private Node head;

private Node tail;

//Node

class Node

{

public Object data;

public Node previous;

public Node next;

}

/**

* Constructs an empty linked list/

*/

public LinkedList()

{

head = null;

tail = null;

}

/**

* Appends a new node to the end of the linked list.

*/

public void append(Object element)

{

if (head == null) //Empty linked list

{

Node firstNode = new Node();

firstNode.data = element;

firstNode.previous = null;

firstNode.next = null;

head = firstNode;

tail = firstNode;

}

else //At least one node already exists.

{

Node newNode = new Node();

newNode.data = element;

newNode.previous = tail;

newNode.next = null;

tail.next = newNode;

tail = newNode;

}

}

//PLEASE START WORK HERE

//===============================================

/**

* Check to see if element is contained

* anywhere in the linked list.

* @returns boolean: true if contained

*/

//===============================================

//PLEASE END WORK HERE

}

Input Input is taken care of for you (in PoD java). It reads in the number of team members, followed by each of the team members' names. Finally, it reads in one more name to check and see if that person has made the team. Processing Complete the co are provided in the Java file at left. ntains method in the LinkedList class. Details of this Output Output is taken care of for you (in PoD java). If the person whose name is being checked against the team roster is on the list (i.e contained in the linked list), PoD java outputs NAME is on the team. otherwise it outputs NAME did not make the tean

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!