**THIS PROBLEM IS IN JAVA** If a class is required to store data inside of a node, the getNode method that exists within
Posted: Fri Jul 01, 2022 5:52 am
**THIS PROBLEM IS IN JAVA**
If a class is required to store data inside of a node, thegetNode method that exists within the node class is called. It willconfirm the presence of a node in the storage, and make a new nodeis one does not already exist in that storage. That same new nodeis then returned and the amount of nodes is incremented. On theother hand, if the storage list is not empty, the head is separatedfrom the list and updated to store the value of the head as aparameter, and the removed node is returned with the number ofnodes not being incremented. If a value is to be deleted, thereleaseNode method will be called on the node with that value,where it will change the value of the node to null and then placethe node at the head of the storage list.
Node class defined below:
** If we define the following constant to be public static finalint MAXIMUM_AMOUNT_OF_NODES = 10;, a custom exception namedMAXIMUMNODESEXCEPTION should be thrown. MAXIMUMNODESEXCEPTION is asubtype of ILLEGALACCESSEXECEPTION (checked exception) inJava.
A) Which one is correct: MAXIMUMNODESEXCEPTION EXTENDSILLEGALACCESSEXCEPTION, OR MAXIMUMNODESEXCEPTION IMPLEMENTSILLEGALACCESSEXCEPTION?
B) Complete a unit test that confirms MAXIMUMNODESEXCEPTIONis being thrown.
public class Node<E> { private E e; // Value for this node private Node<E> next; // Point to next node in list // Constructor Node (E it, Node<E> inn) { e = it; next = inn; } public E element () { return e; } // Return the value public void setElement (E it) { e = it; } // Set element value public Node<E> next () { return next; } // Return next node public void setNext (Node<E> inn) { next = inn; } // Set next node. *****/ * Extensions to support storage list **/ private static Node storagelist = null; // storage list for the class. // define the number of nodes created // TO DO /** *Return a new node, from storage list if it is not empty * @param it - the value to be stored in the new node * @param inn - the follower of the new node * @return the node is empty, a new node is created, if not the head of the * storage list is used to store it **/ public static <E> Node <E> getNode (E it, Node<E> inn) { // TODO } * containing the value it. If the storage list // Return a node to the storage list public void releaseNode () { // TODO } // int get NumNodes () : Return the number of nodes created // TODO To create a new node of String (without a follower node) we write Node <String> n = Node.getNode ("Hello", null); and to release that same node we write n. release ();
If a class is required to store data inside of a node, thegetNode method that exists within the node class is called. It willconfirm the presence of a node in the storage, and make a new nodeis one does not already exist in that storage. That same new nodeis then returned and the amount of nodes is incremented. On theother hand, if the storage list is not empty, the head is separatedfrom the list and updated to store the value of the head as aparameter, and the removed node is returned with the number ofnodes not being incremented. If a value is to be deleted, thereleaseNode method will be called on the node with that value,where it will change the value of the node to null and then placethe node at the head of the storage list.
Node class defined below:
** If we define the following constant to be public static finalint MAXIMUM_AMOUNT_OF_NODES = 10;, a custom exception namedMAXIMUMNODESEXCEPTION should be thrown. MAXIMUMNODESEXCEPTION is asubtype of ILLEGALACCESSEXECEPTION (checked exception) inJava.
A) Which one is correct: MAXIMUMNODESEXCEPTION EXTENDSILLEGALACCESSEXCEPTION, OR MAXIMUMNODESEXCEPTION IMPLEMENTSILLEGALACCESSEXCEPTION?
B) Complete a unit test that confirms MAXIMUMNODESEXCEPTIONis being thrown.
public class Node<E> { private E e; // Value for this node private Node<E> next; // Point to next node in list // Constructor Node (E it, Node<E> inn) { e = it; next = inn; } public E element () { return e; } // Return the value public void setElement (E it) { e = it; } // Set element value public Node<E> next () { return next; } // Return next node public void setNext (Node<E> inn) { next = inn; } // Set next node. *****/ * Extensions to support storage list **/ private static Node storagelist = null; // storage list for the class. // define the number of nodes created // TO DO /** *Return a new node, from storage list if it is not empty * @param it - the value to be stored in the new node * @param inn - the follower of the new node * @return the node is empty, a new node is created, if not the head of the * storage list is used to store it **/ public static <E> Node <E> getNode (E it, Node<E> inn) { // TODO } * containing the value it. If the storage list // Return a node to the storage list public void releaseNode () { // TODO } // int get NumNodes () : Return the number of nodes created // TODO To create a new node of String (without a follower node) we write Node <String> n = Node.getNode ("Hello", null); and to release that same node we write n. release ();