Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

AssassinManager(final String[] names) ? This constructor should initialize the A

ID: 3537028 • Letter: A

Question

AssassinManager(final String[] names) ? This constructor should initialize the AssassinManager %u201Ckill ring%u201D with the players in the provided array. The first player (element 0) is targeting the second player (element 1), the second player (element 1) is targeting the third player (element 2), etc., and the last player (element names.length %u2013 1) is targeting the first player (element 0). The %u201Cgraveyard%u201D should begin empty. If the names array is empty, this method should throw an IllegalArgumentException.

This is a constructore and I have an arrayList with names.

Explanation / Answer

class Node{

Node target;

String name;

Node(String n)

{

name=n;

target=null;

}

}


class AssassinManager(final String[] names)

{

Node LinkedList;

//REQUESTED CONSTRUCTOR

AssassinManager(final String[] names)

{

int l=names.length;

LinkedList =new Node(names[0]);

Node prev= LinkedList;

Node current;

for(int i=1;i<l;i++)

{

current = new Node(names[i]);

prev.target = current;

}

current.target = LinkedList;

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote