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

Need to change the doubly linked node structure where the type of the value is c

ID: 3625697 • Letter: N

Question

Need to change the doubly linked node structure where the type of the value is comparable.

public class DNodeC {

private int item;
private DNodeC next;
private DNodeC prev;

public DNodeC (int newItem) {
item = newItem;
next=null;
prev=null;
}

public DNodeC (int newItem, DNodeC nextNode, DNodeC prevNode) {

item = newItem;
next = nextNode;
prev = prevNode;
}



public void setItem(int newItem) {
item = newItem;
}

public int getItem() {
return item;
}

public void setNext(DNodeC newNode){
next = newNode;
}


public DNodeC getNext(){
return next;
}

public void setPrev( DNodeC newNode){
prev = newNode;
}

public DNodeC getPrev() {
return prev;
}

}// end class Dnode

Explanation / Answer

Like this? public class DNodeC { private Comparable item; private DNodeC next; private DNodeC prev; public DNodeC (Comparable newItem) { item = newItem; next=null; prev=null; } public DNodeC (Comparable newItem, DNodeC nextNode, DNodeC prevNode) { item = newItem; next = nextNode; prev = prevNode; } public void setItem(Comparable newItem) { item = newItem; } public Comparable getItem() { return item; } public void setNext(DNodeC newNode){ next = newNode; } public DNodeC getNext(){ return next; } public void setPrev( DNodeC newNode){ prev = newNode; } public DNodeC getPrev() { return prev; } }

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