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; } }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.