Question: import java.util.Scanner; public class PoD { public static void main( String [] args ) { Scanner in = new Scanner( System.in ); LinkedList teamListSummer =

 import java.util.Scanner; public class PoD { public static void main( String[] args ) { Scanner in = new Scanner( System.in ); LinkedListteamListSummer = new LinkedList(); final int TEAM_SIZE = Integer.valueOf(in.nextLine()); for (int i=0;i { String newTeamMember = in.nextLine(); teamListSummer.append(newTeamMember); } LinkedList teamListFall = new

import java.util.Scanner;

public class PoD

{

public static void main( String [] args )

{

Scanner in = new Scanner( System.in );

LinkedList teamListSummer = new LinkedList();

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

for (int i=0; i

{

String newTeamMember = in.nextLine();

teamListSummer.append(newTeamMember);

}

LinkedList teamListFall = new LinkedList();

teamListFall = teamListSummer.clone();

System.out.println("SUMMER TEAM:");

System.out.println(teamListSummer);

System.out.println("FALL TEAM:");

System.out.println(teamListFall);

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 clone 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;

}

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

/**

* METHOD: clone()

* clones the existing linked list

*

* @returns Object: clone of the linked list itself

*/

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

/**

* 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;

}

}

public String toString()

{

Node position = head;

String output = "";

while (position != null)

{

output += position.data + " ";

position = position.next;

}

return output;

}

}

Today you are going to be revisiting our team roster. It turns out that those players that like sports really do like sports. After a great season of summer games, we are now filling the roster for the fall teams and it turns out we are getting the same number of usual suspects. Everyone from our first team roster is back at it for the fall. We could have just cloned the roster and been done with it! In fact, why don't we? Once more, much of the linked list has already been implemented, including a constructor and append method. You will have to implement a new clone) method which constructs and returns a copy of the object. Details Input Input is taken care of for you (in PoDjava). It reads in the number of team members, followed by each of the team members names Processing Complete the clone method in the LinkedList class. Details of this are provided in the Java file at left. The class must implement the Cloneable interface. Otherwise, a CloneNotSupportedException is thrown. Output Output is taken care of for you (in PoD java) Team rosters of our "Summer Team and "Fall Team are output. Examples Sample PoDjava input Barney Stinson Ted Mosby Robin Scherbatsky Sample PoD java output SUMMER TEAM: Barney Stinson Ted Mosby Robin Scherbatsky FALL TEAM: Barney Stinson Ted Mosby

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!