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

Dene and implement all appropriate contracts using the adbc tool (and design by

ID: 3799201 • Letter: D

Question

Dene and implement all appropriate contracts using the adbc tool (and design by contract), such as @invariant for invariant, @requires for preconditions, @ensures for postconditions.

5

3 Defining class Node A Node has two parts: 1. data holds the element, of some generic type E, stored in the current node, and 2. next holds a reference to the next node in the list. The interface of Node is defined as follows: public Node (E data) Constructor. precondition: The specified data is not null. postcondition: None. public void setData (E data) Sets the value of the data element. precondition: The specified data is not null. postcondition: None. public E getDataC) Returns the value of data element. precondition: None. postcondition: None. public void setNext (Node next) Sets the next node. precondition: The specified node is not null. postcondition: The specified node is currently accessible through next. public Node getNext() Obtains the next node. precondition: None postcondition: None.

Explanation / Answer

class Node
{
Node newNode;
public Node(E data)
{
if(data != null)
   {
   setData(data);
   }
}

public void setData(E data)
{
if(data != null)
   {
   newNode->data = data;
   }
}

public E getData()
{
return newNode;
}

public void setNext(Node next)
{
if(next != null)
   {
   newNode->next = next;
   }
}

public void getNext()
{
return newNode->next;
}
}

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