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

This is for java and i need help with these two classes. UML DIAGRAM FOR AND DIS

ID: 3937710 • Letter: T

Question

This is for java and i need help with these two classes.

UML DIAGRAM FOR AND DISCUSSION FOR EmptyListException

EmptyListException extends RuntimeException

<<constructor>>EmptyListException( )

<<constructor>>EmptyListException(name : String)

Constructors

The constructor that takes a String as an argument calls upon the super class constructor with that String concatenated with “ is Empty”. The constructor that takes no argument calls upon the other constructor with the argument of “List”.

This class should belong to the exceptions package.

UML DIAGRAM FOR AND DISCUSSION FOR ListNode

ListNode<E extends Comparable<E>>

data : E

nextNode: ListNode<E>

<<constructor>>ListNode(d : E)

<<constructor>>ListNode(d : E, node : ListNode<E>)

+ setData(d : E)

+getData() : E

+setNext(next : ListNode<E>)

+getNext() : ListNode<E>

Notes on ListNode

ListNode(d : E) sets the nextNode to null, the rest of the implementation of the ListNode class is self-explanatory as discussed in class

EmptyListException extends RuntimeException

<<constructor>>EmptyListException( )

<<constructor>>EmptyListException(name : String)

Explanation / Answer

public class ListNode<E extends Comparable<E>> {
   private E data;
   private ListNode<E> nextNode;

   public ListNode(E data) {
       this.data = data;
       this.nextNode = null;
   }

   public ListNode(E data, ListNode<E> nextNode) {
       this.data = data;
       this.nextNode = nextNode;
   }

   public void setData(E data) {
       this.data = data;
   }

   public E getData() {
       return data;
   }

   public void setNext(ListNode<E> nextNode) {
       this.nextNode = nextNode;
   }

   public ListNode<E> getNext() {
       return nextNode;
   }

}

public class EmptyListException extends RuntimeException {
   /**
   *
   */
   public EmptyListException() {
       // TODO Auto-generated constructor stub
       this("List");
   }

   /**
   * @param name
   */
   public EmptyListException(String name) {
       // TODO Auto-generated constructor stub
       super(name + " is Empty");
   }
}

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