SlideShare a Scribd company logo
Help please!!
(Include your modified DList.java source code file in your homework solution zip archive)
Using
whatever Java IDE you prefer, create a project and add DList.java and DListTest.java to it (these
files are provided
in the Week 6 Source zip archive). Modify DList to implement a method that removes all
occurrences of a specific
integer from the list. Here is the pseudocode:
Method removeAll(In: Integer pData) Returns Nothing
Define index variable i and initialize i to 0
While i < the size of this Dlist Do
If get(i) equals pData Then
remove(i)
Else
Increment i
End If
End While
End Method removeAll
Next, modify DListTest() to add test case 21 which tests that removeAll() works correctly.
WHat more do i need to provide to get help on this???
Solution
/* DListNode.java */
/**
* A DListNode is a node in a DList (doubly-linked list).
*/
class DListNode {
/**
* item references the item stored in the current node.
* prev references the previous node in the DList.
* next references the next node in the DList.
*
* DO NOT CHANGE THE FOLLOWING FIELD DECLARATIONS.
*/
public Object item;
protected DListNode prev;
protected DListNode next;
/**
* DListNode() constructor.
* @param i the item to store in the node.
* @param p the node previous to this node.
* @param n the node following this node.
*/
DListNode(Object i, DListNode p, DListNode n) {
item = i;
prev = p;
next = n;
}
}
/* DList.java */
/**
* A DList is a mutable doubly-linked list ADT. Its implementation is
* circularly-linked and employs a sentinel (dummy) node at the head
* of the list.
*
* DO NOT CHANGE ANY METHOD PROTOTYPES IN THIS FILE.
*/
class DList {
/**
* head references the sentinel node.
* size is the number of items in the list. (The sentinel node does not
* store an item.)
*
* DO NOT CHANGE THE FOLLOWING FIELD DECLARATIONS.
*/
protected DListNode head;
protected int size;
/* DList invariants:
* 1) head != null.
* 2) For any DListNode x in a DList, x.next != null.
* 3) For any DListNode x in a DList, x.prev != null.
* 4) For any DListNode x in a DList, if x.next == y, then y.prev == x.
* 5) For any DListNode x in a DList, if x.prev == y, then y.next == x.
* 6) size is the number of DListNodes, NOT COUNTING the sentinel,
* that can be accessed from the sentinel (head) by a sequence of
* "next" references.
*/
/**
* newNode() calls the DListNode constructor. Use this class to allocate
* new DListNodes rather than calling the DListNode constructor directly.
* That way, only this method needs to be overridden if a subclass of DList
* wants to use a different kind of node.
* @param item the item to store in the node.
* @param prev the node previous to this node.
* @param next the node following this node.
*/
protected DListNode newNode(Object item, DListNode prev, DListNode next) {
return new DListNode(item, prev, next);
}
/**
* DList() constructor for an empty DList.
*/
public DList() {
// Your solution here.
head = newNode(null, head, head);
head.prev = head;
head.next = head;
size = 0;
}
/**
* isEmpty() returns true if this DList is empty, false otherwise.
* @return true if this DList is empty, false otherwise.
* Performance: runs in O(1) time.
*/
public boolean isEmpty() {
return size == 0;
}
/**
* length() returns the length of this DList.
* @return the length of this DList.
* Performance: runs in O(1) time.
*/
public int length() {
return size;
}
/**
* insertFront() inserts an item at the front of this DList.
* @param item is the item to be inserted.
* Performance: runs in O(1) time.
*/
public void insertFront(Object item) {
// Your solution here.
head.next.prev = newNode(item, head, head.next);
head.next = head.next.prev;
size++;
}
/**
* insertBack() inserts an item at the back of this DList.
* @param item is the item to be inserted.
* Performance: runs in O(1) time.
*/
public void insertBack(Object item) {
// Your solution here.
head.prev.next = newNode(item, head.prev, head);
head.prev = head.prev.next;
size++;
}
/**
* front() returns the node at the front of this DList. If the DList is
* empty, return null.
*
* Do NOT return the sentinel under any circumstances!
*
* @return the node at the front of this DList.
* Performance: runs in O(1) time.
*/
public DListNode front() {
// Your solution here.
if (isEmpty()) {
return null;
}
return head.next;
}
/**
* back() returns the node at the back of this DList. If the DList is
* empty, return null.
*
* Do NOT return the sentinel under any circumstances!
*
* @return the node at the back of this DList.
* Performance: runs in O(1) time.
*/
public DListNode back() {
// Your solution here.
if (isEmpty()) {
return null;
}
return head.prev;
}
/**
* next() returns the node following "node" in this DList. If "node" is
* null, or "node" is the last node in this DList, return null.
*
* Do NOT return the sentinel under any circumstances!
*
* @param node the node whose successor is sought.
* @return the node following "node".
* Performance: runs in O(1) time.
*/
public DListNode next(DListNode node) {
// Your solution here.
if (node == null || node.next == head) {
return null;
}
return node.next;
}
/**
* prev() returns the node prior to "node" in this DList. If "node" is
* null, or "node" is the first node in this DList, return null.
*
* Do NOT return the sentinel under any circumstances!
*
* @param node the node whose predecessor is sought.
* @return the node prior to "node".
* Performance: runs in O(1) time.
*/
public DListNode prev(DListNode node) {
// Your solution here.
if (node == null || node.prev == head) {
return null;
}
return node.prev;
}
/**
* insertAfter() inserts an item in this DList immediately following "node".
* If "node" is null, do nothing.
* @param item the item to be inserted.
* @param node the node to insert the item after.
* Performance: runs in O(1) time.
*/
public void insertAfter(Object item, DListNode node) {
// Your solution here.
if (node != null) {
node.next.prev = newNode(item, node, node.next);;
node.next = node.next.prev;
size++;
}
}
/**
* insertBefore() inserts an item in this DList immediately before "node".
* If "node" is null, do nothing.
* @param item the item to be inserted.
* @param node the node to insert the item before.
* Performance: runs in O(1) time.
*/
public void insertBefore(Object item, DListNode node) {
// Your solution here.
if (node != null) {
node.prev.next = newNode(item, node.prev, node);
node.prev = node.prev.next;
size++;
}
}
/**
* remove() removes "node" from this DList. If "node" is null, do nothing.
* Performance: runs in O(1) time.
*/
public void remove(DListNode node) {
// Your solution here.
if (node != null) {
node.prev.next = node.next;
node.next.prev = node.prev;
size--;
}
}
/**
* removeAll() removes "node" from this DList. If "node" is null, do nothing.
* Performance: runs in O(1) time.
*/
public void removeAll(Object item) {
// Your solution here.
int i=0;
DListNode current = head.next;
while (current != head) {
if (current.item == item ) remove(current);
current = current.next;
}
if (current.item == item) remove(current);
}
/**
* toString() returns a String representation of this DList.
*
* DO NOT CHANGE THIS METHOD.
*
* @return a String representation of this DList.
* Performance: runs in O(n) time, where n is the length of the list.
*/
public String toString() {
String result = "[ ";
DListNode current = head.next;
while (current != head) {
result = result + current.item + " ";
current = current.next;
}
return result + "]";
}
public static void main(String[] argv) {
System.out.println("Testing Constructor");
DList testList = new DList();
System.out.println("Is empty? Should be true: " + testList.isEmpty());
System.out.println("Should be zero length: " + testList.length());
System.out.println("Should be [ ]: " + testList);
System.out.println(" Testing insertFront");
testList.insertFront(1);
System.out.println("Is empty? Should be false: " + testList.isEmpty());
System.out.println("Should be one length: " + testList.length());
System.out.println("Should be [ 1 ]: " + testList);
System.out.println(" Testing insertBack");
testList.insertBack(3);
System.out.println("Is empty? Should be false: " + testList.isEmpty());
System.out.println("Should be two length: " + testList.length());
System.out.println("Should be [ 1 3 ]: " + testList);
System.out.println(" Testing front()");
System.out.println("This should print out 1: " + testList.front().item);
System.out.println(" Testing back()");
System.out.println("This should print out 3: " + testList.back().item);
System.out.println(" Testing next method");
testList.insertFront(5);
System.out.println("Should be [ 5 1 3 ]: " + testList);
DListNode testingNode = testList.next(testList.front());
System.out.println("This should print out 1: " + testingNode.item);
testingNode = testList.next(testingNode);
System.out.println("This should print out 3: " + testingNode.item);
System.out.println(" Testing prev method");
testingNode = testList.prev(testingNode);
System.out.println("This should print out 1: " + testingNode.item);
System.out.println(" Testing insertBefore");
testList.insertBefore(10, testingNode);
System.out.println("Should print out [ 5 10 1 3 ]: " + testList);
System.out.println(" Testing insertAfter");
testList.insertAfter(40, testingNode);
System.out.println("Should be [ 5 10 1 40 3 ]: " + testList);
System.out.println(" Removing node");
testList.remove(testingNode);
System.out.println("Should be [ 5 10 40 3 ]: " + testList);
System.out.println(testList.length());
DList l = new DList();
System.out.println("  ###Testing insertFront ### Empty list is" + l);
l.insertFront(9);
System.out.println(" Inserting 9 at front.  List with 9 is " + l);
l.insertFront(8);
l.insertFront(7);
System.out.println(" Inserting 7, 8 at the front.  List with 7, 8, 9 is " + l);
l.insertAfter(6, l.head);
System.out.println(" Inserting 6 after head. nList with 6, 7, 8, 9 is "+l);
l.remove(l.head.next);
System.out.println(" Removed head.next, should return a list of 7, 8, 9.  List with 7, 8, 9 is
" + l);
l.insertFront(9);
l.insertFront(8);
System.out.println(" Inserting List 9,8 with 8, 9, 7, 8, 9 is " + l);
l.removeAll(8);
System.out.println(" Removing all 8 from List with 9, 7, 9 is " + l);
}
}
Output refer url : http://ideone.com/Ila9vB

More Related Content

Similar to Help please!!(Include your modified DList.java source code file in.pdf

Java Foundations StackADT-java --- - Defines the interface to a stack.docx
Java Foundations StackADT-java ---  - Defines the interface to a stack.docxJava Foundations StackADT-java ---  - Defines the interface to a stack.docx
Java Foundations StackADT-java --- - Defines the interface to a stack.docx
VictorXUQGloverl
 
I need help in writing the test cases of the below methods i.pdf
I need help in writing the test cases of the below methods i.pdfI need help in writing the test cases of the below methods i.pdf
I need help in writing the test cases of the below methods i.pdf
adianantsolutions
 
JAVA A double-ended queue is a list that allows the addition and.pdf
JAVA A double-ended queue is a list that allows the addition and.pdfJAVA A double-ended queue is a list that allows the addition and.pdf
JAVA A double-ended queue is a list that allows the addition and.pdf
amrishinda
 
JAVA OOP project; desperately need help asap im begging.Been stuck.pdf
JAVA OOP project; desperately need help asap im begging.Been stuck.pdfJAVA OOP project; desperately need help asap im begging.Been stuck.pdf
JAVA OOP project; desperately need help asap im begging.Been stuck.pdf
fantasiatheoutofthef
 
To complete the task, you need to fill in the missing code. I’ve inc.pdf
To complete the task, you need to fill in the missing code. I’ve inc.pdfTo complete the task, you need to fill in the missing code. I’ve inc.pdf
To complete the task, you need to fill in the missing code. I’ve inc.pdf
ezycolours78
 
Required to augment the authors Binary Search Tree (BST) code to .docx
Required to augment the authors Binary Search Tree (BST) code to .docxRequired to augment the authors Binary Search Tree (BST) code to .docx
Required to augment the authors Binary Search Tree (BST) code to .docx
debishakespeare
 
Write a Java Class to Implement a Generic Linked ListYour list mus.pdf
Write a Java Class to Implement a Generic Linked ListYour list mus.pdfWrite a Java Class to Implement a Generic Linked ListYour list mus.pdf
Write a Java Class to Implement a Generic Linked ListYour list mus.pdf
rozakashif85
 
Can someone help me to fix the code please package dlist i.pdf
Can someone help me to fix the code please package dlist i.pdfCan someone help me to fix the code please package dlist i.pdf
Can someone help me to fix the code please package dlist i.pdf
ABHISHEKREADYMADESKO
 
hi i have to write a java program involving link lists. i have a pro.pdf
hi i have to write a java program involving link lists. i have a pro.pdfhi i have to write a java program involving link lists. i have a pro.pdf
hi i have to write a java program involving link lists. i have a pro.pdf
archgeetsenterprises
 
Once you have all the structures working as intended- it is time to co.docx
Once you have all the structures working as intended- it is time to co.docxOnce you have all the structures working as intended- it is time to co.docx
Once you have all the structures working as intended- it is time to co.docx
farrahkur54
 
4. The size of instructions can be fixed or variable. What are advant.pdf
4. The size of instructions can be fixed or variable. What are advant.pdf4. The size of instructions can be fixed or variable. What are advant.pdf
4. The size of instructions can be fixed or variable. What are advant.pdf
mumnesh
 
How do I fix it in LinkedList.javathis is what i didLabProgra.pdf
How do I fix it in LinkedList.javathis is what i didLabProgra.pdfHow do I fix it in LinkedList.javathis is what i didLabProgra.pdf
How do I fix it in LinkedList.javathis is what i didLabProgra.pdf
mail931892
 
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdf
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdfHere is the editable codeSolutionimport java.util.NoSuchEleme.pdf
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdf
arrowmobile
 
Please write in C++ and should be able to compile and debug.Thank yo.pdf
Please write in C++ and should be able to compile and debug.Thank yo.pdfPlease write in C++ and should be able to compile and debug.Thank yo.pdf
Please write in C++ and should be able to compile and debug.Thank yo.pdf
ajaycosmeticslg
 
Need Help with this Java Assignment. Program should be done in JAVA .pdf
Need Help with this Java Assignment. Program should be done in JAVA .pdfNeed Help with this Java Assignment. Program should be done in JAVA .pdf
Need Help with this Java Assignment. Program should be done in JAVA .pdf
archiesgallery
 
File LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdfFile LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdf
Conint29
 
Implement the additional 5 methods as indicated in the LinkedList fi.pdf
Implement the additional 5 methods as indicated in the LinkedList fi.pdfImplement the additional 5 methods as indicated in the LinkedList fi.pdf
Implement the additional 5 methods as indicated in the LinkedList fi.pdf
footstatus
 
package singlylinkedlist; public class Node { public String valu.pdf
package singlylinkedlist; public class Node { public String valu.pdfpackage singlylinkedlist; public class Node { public String valu.pdf
package singlylinkedlist; public class Node { public String valu.pdf
amazing2001
 
justbasics.pdf
justbasics.pdfjustbasics.pdf
justbasics.pdf
DrRajkumarKhatri
 
Write the following using javaGiven a class ‘Node’ and ‘NodeList’,.pdf
Write the following using javaGiven a class ‘Node’ and ‘NodeList’,.pdfWrite the following using javaGiven a class ‘Node’ and ‘NodeList’,.pdf
Write the following using javaGiven a class ‘Node’ and ‘NodeList’,.pdf
fathimalinks
 

Similar to Help please!!(Include your modified DList.java source code file in.pdf (20)

Java Foundations StackADT-java --- - Defines the interface to a stack.docx
Java Foundations StackADT-java ---  - Defines the interface to a stack.docxJava Foundations StackADT-java ---  - Defines the interface to a stack.docx
Java Foundations StackADT-java --- - Defines the interface to a stack.docx
 
I need help in writing the test cases of the below methods i.pdf
I need help in writing the test cases of the below methods i.pdfI need help in writing the test cases of the below methods i.pdf
I need help in writing the test cases of the below methods i.pdf
 
JAVA A double-ended queue is a list that allows the addition and.pdf
JAVA A double-ended queue is a list that allows the addition and.pdfJAVA A double-ended queue is a list that allows the addition and.pdf
JAVA A double-ended queue is a list that allows the addition and.pdf
 
JAVA OOP project; desperately need help asap im begging.Been stuck.pdf
JAVA OOP project; desperately need help asap im begging.Been stuck.pdfJAVA OOP project; desperately need help asap im begging.Been stuck.pdf
JAVA OOP project; desperately need help asap im begging.Been stuck.pdf
 
To complete the task, you need to fill in the missing code. I’ve inc.pdf
To complete the task, you need to fill in the missing code. I’ve inc.pdfTo complete the task, you need to fill in the missing code. I’ve inc.pdf
To complete the task, you need to fill in the missing code. I’ve inc.pdf
 
Required to augment the authors Binary Search Tree (BST) code to .docx
Required to augment the authors Binary Search Tree (BST) code to .docxRequired to augment the authors Binary Search Tree (BST) code to .docx
Required to augment the authors Binary Search Tree (BST) code to .docx
 
Write a Java Class to Implement a Generic Linked ListYour list mus.pdf
Write a Java Class to Implement a Generic Linked ListYour list mus.pdfWrite a Java Class to Implement a Generic Linked ListYour list mus.pdf
Write a Java Class to Implement a Generic Linked ListYour list mus.pdf
 
Can someone help me to fix the code please package dlist i.pdf
Can someone help me to fix the code please package dlist i.pdfCan someone help me to fix the code please package dlist i.pdf
Can someone help me to fix the code please package dlist i.pdf
 
hi i have to write a java program involving link lists. i have a pro.pdf
hi i have to write a java program involving link lists. i have a pro.pdfhi i have to write a java program involving link lists. i have a pro.pdf
hi i have to write a java program involving link lists. i have a pro.pdf
 
Once you have all the structures working as intended- it is time to co.docx
Once you have all the structures working as intended- it is time to co.docxOnce you have all the structures working as intended- it is time to co.docx
Once you have all the structures working as intended- it is time to co.docx
 
4. The size of instructions can be fixed or variable. What are advant.pdf
4. The size of instructions can be fixed or variable. What are advant.pdf4. The size of instructions can be fixed or variable. What are advant.pdf
4. The size of instructions can be fixed or variable. What are advant.pdf
 
How do I fix it in LinkedList.javathis is what i didLabProgra.pdf
How do I fix it in LinkedList.javathis is what i didLabProgra.pdfHow do I fix it in LinkedList.javathis is what i didLabProgra.pdf
How do I fix it in LinkedList.javathis is what i didLabProgra.pdf
 
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdf
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdfHere is the editable codeSolutionimport java.util.NoSuchEleme.pdf
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdf
 
Please write in C++ and should be able to compile and debug.Thank yo.pdf
Please write in C++ and should be able to compile and debug.Thank yo.pdfPlease write in C++ and should be able to compile and debug.Thank yo.pdf
Please write in C++ and should be able to compile and debug.Thank yo.pdf
 
Need Help with this Java Assignment. Program should be done in JAVA .pdf
Need Help with this Java Assignment. Program should be done in JAVA .pdfNeed Help with this Java Assignment. Program should be done in JAVA .pdf
Need Help with this Java Assignment. Program should be done in JAVA .pdf
 
File LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdfFile LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdf
 
Implement the additional 5 methods as indicated in the LinkedList fi.pdf
Implement the additional 5 methods as indicated in the LinkedList fi.pdfImplement the additional 5 methods as indicated in the LinkedList fi.pdf
Implement the additional 5 methods as indicated in the LinkedList fi.pdf
 
package singlylinkedlist; public class Node { public String valu.pdf
package singlylinkedlist; public class Node { public String valu.pdfpackage singlylinkedlist; public class Node { public String valu.pdf
package singlylinkedlist; public class Node { public String valu.pdf
 
justbasics.pdf
justbasics.pdfjustbasics.pdf
justbasics.pdf
 
Write the following using javaGiven a class ‘Node’ and ‘NodeList’,.pdf
Write the following using javaGiven a class ‘Node’ and ‘NodeList’,.pdfWrite the following using javaGiven a class ‘Node’ and ‘NodeList’,.pdf
Write the following using javaGiven a class ‘Node’ and ‘NodeList’,.pdf
 

More from jyothimuppasani1

How does an open source operating system like Linux® affect Internet.pdf
How does an open source operating system like Linux® affect Internet.pdfHow does an open source operating system like Linux® affect Internet.pdf
How does an open source operating system like Linux® affect Internet.pdf
jyothimuppasani1
 
how can I replace the Newsfeed text with a custom on in SharePoi.pdf
how can I replace the Newsfeed text with a custom on in SharePoi.pdfhow can I replace the Newsfeed text with a custom on in SharePoi.pdf
how can I replace the Newsfeed text with a custom on in SharePoi.pdf
jyothimuppasani1
 
Hello!This is Java assignment applet.Can someone help me writing.pdf
Hello!This is Java assignment applet.Can someone help me writing.pdfHello!This is Java assignment applet.Can someone help me writing.pdf
Hello!This is Java assignment applet.Can someone help me writing.pdf
jyothimuppasani1
 
For each of the following reseach questions identify the observation.pdf
For each of the following reseach questions identify the observation.pdfFor each of the following reseach questions identify the observation.pdf
For each of the following reseach questions identify the observation.pdf
jyothimuppasani1
 
Find an Eulerian trail in the following graph. Be sure to indicate th.pdf
Find an Eulerian trail in the following graph. Be sure to indicate th.pdfFind an Eulerian trail in the following graph. Be sure to indicate th.pdf
Find an Eulerian trail in the following graph. Be sure to indicate th.pdf
jyothimuppasani1
 
File encryption. [32] Write a program which accepts a filename as a .pdf
File encryption. [32] Write a program which accepts a filename as a .pdfFile encryption. [32] Write a program which accepts a filename as a .pdf
File encryption. [32] Write a program which accepts a filename as a .pdf
jyothimuppasani1
 
Explain the relevance that medical standards of practice have to one.pdf
Explain the relevance that medical standards of practice have to one.pdfExplain the relevance that medical standards of practice have to one.pdf
Explain the relevance that medical standards of practice have to one.pdf
jyothimuppasani1
 
Find the mission and values statements for four different hospita.pdf
Find the mission and values statements for four different hospita.pdfFind the mission and values statements for four different hospita.pdf
Find the mission and values statements for four different hospita.pdf
jyothimuppasani1
 
Did colonial rule freeze colonized societies by preserving old s.pdf
Did colonial rule freeze colonized societies by preserving old s.pdfDid colonial rule freeze colonized societies by preserving old s.pdf
Did colonial rule freeze colonized societies by preserving old s.pdf
jyothimuppasani1
 
Do you think that nonhuman animals have interests Does this mean th.pdf
Do you think that nonhuman animals have interests Does this mean th.pdfDo you think that nonhuman animals have interests Does this mean th.pdf
Do you think that nonhuman animals have interests Does this mean th.pdf
jyothimuppasani1
 
Discuss the importance of recognizing and implementing different ent.pdf
Discuss the importance of recognizing and implementing different ent.pdfDiscuss the importance of recognizing and implementing different ent.pdf
Discuss the importance of recognizing and implementing different ent.pdf
jyothimuppasani1
 
Considering the challenges she is facing, what Anitas plan before .pdf
Considering the challenges she is facing, what Anitas plan before .pdfConsidering the challenges she is facing, what Anitas plan before .pdf
Considering the challenges she is facing, what Anitas plan before .pdf
jyothimuppasani1
 
Data Structure in C++Doubly Linked Lists of ints httpstaffwww.pdf
Data Structure in C++Doubly Linked Lists of ints httpstaffwww.pdfData Structure in C++Doubly Linked Lists of ints httpstaffwww.pdf
Data Structure in C++Doubly Linked Lists of ints httpstaffwww.pdf
jyothimuppasani1
 
Conceptual skills are most important at theSolutionConceptual .pdf
Conceptual skills are most important at theSolutionConceptual .pdfConceptual skills are most important at theSolutionConceptual .pdf
Conceptual skills are most important at theSolutionConceptual .pdf
jyothimuppasani1
 
A variable whose scope is restricted to the method where it was decl.pdf
A variable whose scope is restricted to the method where it was decl.pdfA variable whose scope is restricted to the method where it was decl.pdf
A variable whose scope is restricted to the method where it was decl.pdf
jyothimuppasani1
 
•Design (create) 3 questions for a quiz show game and design regular.pdf
•Design (create) 3 questions for a quiz show game and design regular.pdf•Design (create) 3 questions for a quiz show game and design regular.pdf
•Design (create) 3 questions for a quiz show game and design regular.pdf
jyothimuppasani1
 
You are to write a GUI program that will allow a user to buy, sell a.pdf
You are to write a GUI program that will allow a user to buy, sell a.pdfYou are to write a GUI program that will allow a user to buy, sell a.pdf
You are to write a GUI program that will allow a user to buy, sell a.pdf
jyothimuppasani1
 
write the To Dos to get the exact outputNOte A valid Fraction .pdf
write the To Dos to get the exact outputNOte A valid Fraction .pdfwrite the To Dos to get the exact outputNOte A valid Fraction .pdf
write the To Dos to get the exact outputNOte A valid Fraction .pdf
jyothimuppasani1
 
What are the factors that contribute to H+ gain or loss How do lung.pdf
What are the factors that contribute to H+ gain or loss How do lung.pdfWhat are the factors that contribute to H+ gain or loss How do lung.pdf
What are the factors that contribute to H+ gain or loss How do lung.pdf
jyothimuppasani1
 
Write down the four (4) nonlinear regression models covered in class,.pdf
Write down the four (4) nonlinear regression models covered in class,.pdfWrite down the four (4) nonlinear regression models covered in class,.pdf
Write down the four (4) nonlinear regression models covered in class,.pdf
jyothimuppasani1
 

More from jyothimuppasani1 (20)

How does an open source operating system like Linux® affect Internet.pdf
How does an open source operating system like Linux® affect Internet.pdfHow does an open source operating system like Linux® affect Internet.pdf
How does an open source operating system like Linux® affect Internet.pdf
 
how can I replace the Newsfeed text with a custom on in SharePoi.pdf
how can I replace the Newsfeed text with a custom on in SharePoi.pdfhow can I replace the Newsfeed text with a custom on in SharePoi.pdf
how can I replace the Newsfeed text with a custom on in SharePoi.pdf
 
Hello!This is Java assignment applet.Can someone help me writing.pdf
Hello!This is Java assignment applet.Can someone help me writing.pdfHello!This is Java assignment applet.Can someone help me writing.pdf
Hello!This is Java assignment applet.Can someone help me writing.pdf
 
For each of the following reseach questions identify the observation.pdf
For each of the following reseach questions identify the observation.pdfFor each of the following reseach questions identify the observation.pdf
For each of the following reseach questions identify the observation.pdf
 
Find an Eulerian trail in the following graph. Be sure to indicate th.pdf
Find an Eulerian trail in the following graph. Be sure to indicate th.pdfFind an Eulerian trail in the following graph. Be sure to indicate th.pdf
Find an Eulerian trail in the following graph. Be sure to indicate th.pdf
 
File encryption. [32] Write a program which accepts a filename as a .pdf
File encryption. [32] Write a program which accepts a filename as a .pdfFile encryption. [32] Write a program which accepts a filename as a .pdf
File encryption. [32] Write a program which accepts a filename as a .pdf
 
Explain the relevance that medical standards of practice have to one.pdf
Explain the relevance that medical standards of practice have to one.pdfExplain the relevance that medical standards of practice have to one.pdf
Explain the relevance that medical standards of practice have to one.pdf
 
Find the mission and values statements for four different hospita.pdf
Find the mission and values statements for four different hospita.pdfFind the mission and values statements for four different hospita.pdf
Find the mission and values statements for four different hospita.pdf
 
Did colonial rule freeze colonized societies by preserving old s.pdf
Did colonial rule freeze colonized societies by preserving old s.pdfDid colonial rule freeze colonized societies by preserving old s.pdf
Did colonial rule freeze colonized societies by preserving old s.pdf
 
Do you think that nonhuman animals have interests Does this mean th.pdf
Do you think that nonhuman animals have interests Does this mean th.pdfDo you think that nonhuman animals have interests Does this mean th.pdf
Do you think that nonhuman animals have interests Does this mean th.pdf
 
Discuss the importance of recognizing and implementing different ent.pdf
Discuss the importance of recognizing and implementing different ent.pdfDiscuss the importance of recognizing and implementing different ent.pdf
Discuss the importance of recognizing and implementing different ent.pdf
 
Considering the challenges she is facing, what Anitas plan before .pdf
Considering the challenges she is facing, what Anitas plan before .pdfConsidering the challenges she is facing, what Anitas plan before .pdf
Considering the challenges she is facing, what Anitas plan before .pdf
 
Data Structure in C++Doubly Linked Lists of ints httpstaffwww.pdf
Data Structure in C++Doubly Linked Lists of ints httpstaffwww.pdfData Structure in C++Doubly Linked Lists of ints httpstaffwww.pdf
Data Structure in C++Doubly Linked Lists of ints httpstaffwww.pdf
 
Conceptual skills are most important at theSolutionConceptual .pdf
Conceptual skills are most important at theSolutionConceptual .pdfConceptual skills are most important at theSolutionConceptual .pdf
Conceptual skills are most important at theSolutionConceptual .pdf
 
A variable whose scope is restricted to the method where it was decl.pdf
A variable whose scope is restricted to the method where it was decl.pdfA variable whose scope is restricted to the method where it was decl.pdf
A variable whose scope is restricted to the method where it was decl.pdf
 
•Design (create) 3 questions for a quiz show game and design regular.pdf
•Design (create) 3 questions for a quiz show game and design regular.pdf•Design (create) 3 questions for a quiz show game and design regular.pdf
•Design (create) 3 questions for a quiz show game and design regular.pdf
 
You are to write a GUI program that will allow a user to buy, sell a.pdf
You are to write a GUI program that will allow a user to buy, sell a.pdfYou are to write a GUI program that will allow a user to buy, sell a.pdf
You are to write a GUI program that will allow a user to buy, sell a.pdf
 
write the To Dos to get the exact outputNOte A valid Fraction .pdf
write the To Dos to get the exact outputNOte A valid Fraction .pdfwrite the To Dos to get the exact outputNOte A valid Fraction .pdf
write the To Dos to get the exact outputNOte A valid Fraction .pdf
 
What are the factors that contribute to H+ gain or loss How do lung.pdf
What are the factors that contribute to H+ gain or loss How do lung.pdfWhat are the factors that contribute to H+ gain or loss How do lung.pdf
What are the factors that contribute to H+ gain or loss How do lung.pdf
 
Write down the four (4) nonlinear regression models covered in class,.pdf
Write down the four (4) nonlinear regression models covered in class,.pdfWrite down the four (4) nonlinear regression models covered in class,.pdf
Write down the four (4) nonlinear regression models covered in class,.pdf
 

Recently uploaded

Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 

Recently uploaded (20)

Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 

Help please!!(Include your modified DList.java source code file in.pdf

  • 1. Help please!! (Include your modified DList.java source code file in your homework solution zip archive) Using whatever Java IDE you prefer, create a project and add DList.java and DListTest.java to it (these files are provided in the Week 6 Source zip archive). Modify DList to implement a method that removes all occurrences of a specific integer from the list. Here is the pseudocode: Method removeAll(In: Integer pData) Returns Nothing Define index variable i and initialize i to 0 While i < the size of this Dlist Do If get(i) equals pData Then remove(i) Else Increment i End If End While End Method removeAll Next, modify DListTest() to add test case 21 which tests that removeAll() works correctly. WHat more do i need to provide to get help on this??? Solution /* DListNode.java */ /** * A DListNode is a node in a DList (doubly-linked list). */ class DListNode { /** * item references the item stored in the current node. * prev references the previous node in the DList. * next references the next node in the DList. * * DO NOT CHANGE THE FOLLOWING FIELD DECLARATIONS.
  • 2. */ public Object item; protected DListNode prev; protected DListNode next; /** * DListNode() constructor. * @param i the item to store in the node. * @param p the node previous to this node. * @param n the node following this node. */ DListNode(Object i, DListNode p, DListNode n) { item = i; prev = p; next = n; } } /* DList.java */ /** * A DList is a mutable doubly-linked list ADT. Its implementation is * circularly-linked and employs a sentinel (dummy) node at the head * of the list. * * DO NOT CHANGE ANY METHOD PROTOTYPES IN THIS FILE. */ class DList { /** * head references the sentinel node. * size is the number of items in the list. (The sentinel node does not * store an item.) * * DO NOT CHANGE THE FOLLOWING FIELD DECLARATIONS. */ protected DListNode head; protected int size; /* DList invariants:
  • 3. * 1) head != null. * 2) For any DListNode x in a DList, x.next != null. * 3) For any DListNode x in a DList, x.prev != null. * 4) For any DListNode x in a DList, if x.next == y, then y.prev == x. * 5) For any DListNode x in a DList, if x.prev == y, then y.next == x. * 6) size is the number of DListNodes, NOT COUNTING the sentinel, * that can be accessed from the sentinel (head) by a sequence of * "next" references. */ /** * newNode() calls the DListNode constructor. Use this class to allocate * new DListNodes rather than calling the DListNode constructor directly. * That way, only this method needs to be overridden if a subclass of DList * wants to use a different kind of node. * @param item the item to store in the node. * @param prev the node previous to this node. * @param next the node following this node. */ protected DListNode newNode(Object item, DListNode prev, DListNode next) { return new DListNode(item, prev, next); } /** * DList() constructor for an empty DList. */ public DList() { // Your solution here. head = newNode(null, head, head); head.prev = head; head.next = head; size = 0; } /** * isEmpty() returns true if this DList is empty, false otherwise. * @return true if this DList is empty, false otherwise. * Performance: runs in O(1) time. */
  • 4. public boolean isEmpty() { return size == 0; } /** * length() returns the length of this DList. * @return the length of this DList. * Performance: runs in O(1) time. */ public int length() { return size; } /** * insertFront() inserts an item at the front of this DList. * @param item is the item to be inserted. * Performance: runs in O(1) time. */ public void insertFront(Object item) { // Your solution here. head.next.prev = newNode(item, head, head.next); head.next = head.next.prev; size++; } /** * insertBack() inserts an item at the back of this DList. * @param item is the item to be inserted. * Performance: runs in O(1) time. */ public void insertBack(Object item) { // Your solution here. head.prev.next = newNode(item, head.prev, head); head.prev = head.prev.next; size++; } /** * front() returns the node at the front of this DList. If the DList is * empty, return null.
  • 5. * * Do NOT return the sentinel under any circumstances! * * @return the node at the front of this DList. * Performance: runs in O(1) time. */ public DListNode front() { // Your solution here. if (isEmpty()) { return null; } return head.next; } /** * back() returns the node at the back of this DList. If the DList is * empty, return null. * * Do NOT return the sentinel under any circumstances! * * @return the node at the back of this DList. * Performance: runs in O(1) time. */ public DListNode back() { // Your solution here. if (isEmpty()) { return null; } return head.prev; } /** * next() returns the node following "node" in this DList. If "node" is * null, or "node" is the last node in this DList, return null. * * Do NOT return the sentinel under any circumstances! * * @param node the node whose successor is sought.
  • 6. * @return the node following "node". * Performance: runs in O(1) time. */ public DListNode next(DListNode node) { // Your solution here. if (node == null || node.next == head) { return null; } return node.next; } /** * prev() returns the node prior to "node" in this DList. If "node" is * null, or "node" is the first node in this DList, return null. * * Do NOT return the sentinel under any circumstances! * * @param node the node whose predecessor is sought. * @return the node prior to "node". * Performance: runs in O(1) time. */ public DListNode prev(DListNode node) { // Your solution here. if (node == null || node.prev == head) { return null; } return node.prev; } /** * insertAfter() inserts an item in this DList immediately following "node". * If "node" is null, do nothing. * @param item the item to be inserted. * @param node the node to insert the item after. * Performance: runs in O(1) time. */ public void insertAfter(Object item, DListNode node) { // Your solution here.
  • 7. if (node != null) { node.next.prev = newNode(item, node, node.next);; node.next = node.next.prev; size++; } } /** * insertBefore() inserts an item in this DList immediately before "node". * If "node" is null, do nothing. * @param item the item to be inserted. * @param node the node to insert the item before. * Performance: runs in O(1) time. */ public void insertBefore(Object item, DListNode node) { // Your solution here. if (node != null) { node.prev.next = newNode(item, node.prev, node); node.prev = node.prev.next; size++; } } /** * remove() removes "node" from this DList. If "node" is null, do nothing. * Performance: runs in O(1) time. */ public void remove(DListNode node) { // Your solution here. if (node != null) { node.prev.next = node.next; node.next.prev = node.prev; size--; } } /** * removeAll() removes "node" from this DList. If "node" is null, do nothing. * Performance: runs in O(1) time.
  • 8. */ public void removeAll(Object item) { // Your solution here. int i=0; DListNode current = head.next; while (current != head) { if (current.item == item ) remove(current); current = current.next; } if (current.item == item) remove(current); } /** * toString() returns a String representation of this DList. * * DO NOT CHANGE THIS METHOD. * * @return a String representation of this DList. * Performance: runs in O(n) time, where n is the length of the list. */ public String toString() { String result = "[ "; DListNode current = head.next; while (current != head) { result = result + current.item + " "; current = current.next; } return result + "]"; } public static void main(String[] argv) { System.out.println("Testing Constructor"); DList testList = new DList(); System.out.println("Is empty? Should be true: " + testList.isEmpty()); System.out.println("Should be zero length: " + testList.length()); System.out.println("Should be [ ]: " + testList); System.out.println(" Testing insertFront");
  • 9. testList.insertFront(1); System.out.println("Is empty? Should be false: " + testList.isEmpty()); System.out.println("Should be one length: " + testList.length()); System.out.println("Should be [ 1 ]: " + testList); System.out.println(" Testing insertBack"); testList.insertBack(3); System.out.println("Is empty? Should be false: " + testList.isEmpty()); System.out.println("Should be two length: " + testList.length()); System.out.println("Should be [ 1 3 ]: " + testList); System.out.println(" Testing front()"); System.out.println("This should print out 1: " + testList.front().item); System.out.println(" Testing back()"); System.out.println("This should print out 3: " + testList.back().item); System.out.println(" Testing next method"); testList.insertFront(5); System.out.println("Should be [ 5 1 3 ]: " + testList); DListNode testingNode = testList.next(testList.front()); System.out.println("This should print out 1: " + testingNode.item); testingNode = testList.next(testingNode); System.out.println("This should print out 3: " + testingNode.item); System.out.println(" Testing prev method"); testingNode = testList.prev(testingNode); System.out.println("This should print out 1: " + testingNode.item); System.out.println(" Testing insertBefore"); testList.insertBefore(10, testingNode); System.out.println("Should print out [ 5 10 1 3 ]: " + testList); System.out.println(" Testing insertAfter"); testList.insertAfter(40, testingNode); System.out.println("Should be [ 5 10 1 40 3 ]: " + testList); System.out.println(" Removing node"); testList.remove(testingNode); System.out.println("Should be [ 5 10 40 3 ]: " + testList); System.out.println(testList.length()); DList l = new DList(); System.out.println(" ###Testing insertFront ### Empty list is" + l); l.insertFront(9);
  • 10. System.out.println(" Inserting 9 at front. List with 9 is " + l); l.insertFront(8); l.insertFront(7); System.out.println(" Inserting 7, 8 at the front. List with 7, 8, 9 is " + l); l.insertAfter(6, l.head); System.out.println(" Inserting 6 after head. nList with 6, 7, 8, 9 is "+l); l.remove(l.head.next); System.out.println(" Removed head.next, should return a list of 7, 8, 9. List with 7, 8, 9 is " + l); l.insertFront(9); l.insertFront(8); System.out.println(" Inserting List 9,8 with 8, 9, 7, 8, 9 is " + l); l.removeAll(8); System.out.println(" Removing all 8 from List with 9, 7, 9 is " + l); } } Output refer url : http://ideone.com/Ila9vB