SlideShare a Scribd company logo
LabProgram.java
import java.util.NoSuchElementException;
public class LinkedList {
private class Node {
private T data;
private Node next;
private Node prev;
public Node(T data) {
this.data = data;
this.next = null;
this.prev = null;
}
}
private int length;
private Node first;
private Node last;
private Node iterator;
/**** CONSTRUCTORS ****/
/**
* Instantiates a new LinkedList with default values
* @postcondition
*/
public LinkedList() {
first = null;
last = null;
iterator = null;
length = 0;
}
/**
* Converts the given array into a LinkedList
* @param array the array of values to insert into this LinkedList
* @postcondition
*/
public LinkedList(T[] array) {
}
/**
* Instantiates a new LinkedList by copying another List
* @param original the LinkedList to copy
* @postcondition a new List object, which is an identical,
* but separate, copy of the LinkedList original
*/
public LinkedList(LinkedList original) {
}
/**** ACCESSORS ****/
/**
* Returns the value stored in the first node
* @precondition <>
* @return the value stored at node first
* @throws NoSuchElementException <>
*/
public T getFirst() throws NoSuchElementException {
if (isEmpty()){
throw new NoSuchElementException("The list is empty");
}
return first.data;
}
/**
* Returns the value stored in the last node
* @precondition <>
* @return the value stored in the node last
* @throws NoSuchElementException <>
*/
public T getLast() throws NoSuchElementException {
if (isEmpty()){
throw new NoSuchElementException("The list is empty");
}
return last.data;
}
/**
* Returns the data stored in the iterator node
* @precondition
* @return the data stored in the iterator node
* @throw NullPointerException
*/
public T getIterator() throws NullPointerException {
return iterator.data;
}
/**
* Returns the current length of the LinkedList
* @return the length of the LinkedList from 0 to n
*/
public int getLength() {
return length;
}
/**
* Returns whether the LinkedList is currently empty
* @return whether the LinkedList is empty
*/
public boolean isEmpty() {
return length == 0;
}
/**
* Returns whether the iterator is offEnd, i.e. null
* @return whether the iterator is null
*/
public boolean offEnd() {
return iterator == null;
}
/**** MUTATORS ****/
/**
* Creates a new first element
* @param data the data to insert at the front of the LinkedList
* @postcondition <>
*/
public void addFirst(T data) {
Node newNode = new Node(data);
if(isEmpty()){
first = newNode;
last = newNode;
}
else{
newNode.next = first;
first.prev = newNode;
first = newNode;
}
length++;
}
/**
* Creates a new last element
* @param data the data to insert at the end of the LinkedList
* @postcondition <>
*/
public void addLast(T data) {
Node newNode = new Node(data);
if(isEmpty()){
first = newNode;
last = newNode;
}
else{
last.next = newNode;
newNode.prev = last;
last = newNode;
}
length++;
}
/**
* Inserts a new element after the iterator
* @param data the data to insert
* @precondition
* @throws NullPointerException
*/
public void addIterator(T data) throws NullPointerException{
return;
}
/**
* removes the element at the front of the LinkedList
*/
public void removeFirst() throws NoSuchElementException {
if(isEmpty()){
throw new NoSuchElementException("The list is empty");
}
if(length == 1){
first = null;
last = null;
iterator = null;
}
else{
if(iterator == first){
iterator = null;
}
first = first.next;
first.prev = null;
}
length--;
}
/**
* removes the element at the end of the LinkedList
*/
public void removeLast() throws NoSuchElementException {
if(isEmpty()){
throw new NoSuchElementException("The list is empty");
}
if(length == 1){
first = null;
last = null;
iterator = null;
}
else{
if(iterator == last){
iterator = null;
}
last = last.prev;
last.next = null;
}
length--;
}
/**
* removes the element referenced by the iterator
* @precondition
* @postcondition
* @throws NullPointerException
*/
public void removeIterator() throws NullPointerException {
}
/**
* places the iterator at the first node
* @postcondition
*/
public void positionIterator(){
}
/**
* Moves the iterator one node towards the last
* @precondition
* @postcondition
* @throws NullPointerException
*/
public void advanceIterator() throws NullPointerException {
}
/**
* Moves the iterator one node towards the first
* @precondition
* @postcondition
* @throws NullPointerException
*/
public void reverseIterator() throws NullPointerException {
}
/**** ADDITIONAL OPERATIONS ****/
/**
* Re-sets LinkedList to empty as if the
* default constructor had just been called
*/
public void clear() {
first = null;
last = null;
iterator = null;
length = 0;
}
/**
* Converts the LinkedList to a String, with each value separated by a blank
* line At the end of the String, place a new line character
* @return the LinkedList as a String
*/
@Override
public String toString() {
StringBuilder result = new StringBuilder();
Node temp = first;
while (temp != null){
result.append(temp.data + " ");
temp = temp.next;
}
return result.toString() + "n";
}
/**
* Determines whether the given Object is
* another LinkedList, containing
* the same data in the same order
* @param obj another Object
* @return whether there is equality
*/
@SuppressWarnings("unchecked") //good practice to remove warning here
@Override public boolean equals(Object obj) {
return false;
}
/**CHALLENGE METHODS*/
/**
* Moves all nodes in the list towards the end
* of the list the number of times specified
* Any node that falls off the end of the list as it
* moves forward will be placed the front of the list
* For example: [1, 2, 3, 4, 5], numMoves = 2 -> [4, 5, 1, 2 ,3]
* For example: [1, 2, 3, 4, 5], numMoves = 4 -> [2, 3, 4, 5, 1]
* For example: [1, 2, 3, 4, 5], numMoves = 7 -> [4, 5, 1, 2 ,3]
* @param numMoves the number of times to move each node.
* @precondition numMoves >= 0
* @postcondition iterator position unchanged (i.e. still referencing
* the same node in the list, regardless of new location of Node)
* @throws IllegalArgumentException when numMoves < 0
*/
public void spinList(int numMoves) throws IllegalArgumentException{
}
/**
* Splices together two LinkedLists to create a third List
* which contains alternating values from this list
* and the given parameter
* For example: [1,2,3] and [4,5,6] -> [1,4,2,5,3,6]
* For example: [1, 2, 3, 4] and [5, 6] -> [1, 5, 2, 6, 3, 4]
* For example: [1, 2] and [3, 4, 5, 6] -> [1, 3, 2, 4, 5, 6]
* @param list the second LinkedList
* @return a new LinkedList, which is the result of
* interlocking this and list
* @postcondition this and list are unchanged
*/
public LinkedList altLists(LinkedList list) {
return null;
}
}
Within your LinkedList class, see the field: private Node iterator; Notice that the iterator begins
at null, as defined by the LinkedList constructors. Take a moment now to update your default
constructor to set iterator = null; Also, look back at removefirst () and removeLast(). Consider
now what will happen if the iterator is at the first or last Node when these methods are called.
Update the methods to handle these edge cases now. We will develop additional methods during
this lab to work with the iterator. Remember to fill in the pre-and postconditions for each
method, as needed. Also inspect the LabProgram. java file and notice that the main () method of
the LabProgram creates a list of numbers and inserts each into a list. The main() method then
calls various iterator methods, displaying results of the method operation. Use Develop mode to
test your Linked List iterator code as you develop it. In Submit mode you will need to complete
all lab steps to pass all automatic tests. Step 2: Implement positionIterator() Method
positionIterator() moves the iterator to the beginning of the list. public void positionIterator() //
fill in here } public void positionIterator() ( // fill in here } Step 3: Implement offEnd() Method
offEnd () returns whether the iterator is off the end of the list, i.e. set to null. Step 4: Implement
getIterator() Method getIterator() returns the element in the Node where the iterator is currently
located. Step 5: Implement advanceIterator() Method advanceIterator () moves the iterator
forward by one node towards the last node. Step 6: Implement reverseIterator( ) Method
reverseIterator () moves the iterator back by one node towards the first node. Step 7: Implement
additerator() Method addIterator() inserts an element after the iterator. Step 8: Implement
removeIterator() Method removeIterator () removes the Node currently referenced by the iterator
and sets the iterator to null.
t java.util.scanner; c class LabProgram { ublic static void main(string[] args) { LabProgram lab
= new LabProgram(); // Make and display List LinkedList Integer list = new LinkedList >(); for
(int i=1;i<4;i++){ list. addLast (i); } System.out.print("Created list: " + list.tostring()); //
tostring() has system. out.println("list.offEnd(): " + list.offEnd()); system.out.println("list.
positionIterator()"); list.positionIterator(); system.out.println("list.offend(): " + list.offEnd());
system.out.println("list.getiterator(): " + list.getiterator ()); list.advanceiterator();
System.out.println("list.getiterator (): " + list.getiterator ());
system.out.println("list.advanceIterator ( )n); list.advanceIterator();
System.out.println("list.getiterator(): " + list.getiterator()); system.out.println("list.
reverseIterator ()n); list. reverseiterator(); System.out.println("list.getiterator(): " +
list.getiterator()); system.out.println("list.additerator (42)"); list.addIterator (42);
System.out.println("list.getiterator(): " + list.getiterator()); system.out.print "list. tostring(): " +
list.tostring()); system.out.println("list.advanceIterator ( )n); list. advanceiterator();
system.out.println("list.advanceIterator ( )n); list.advanceiterator();
System.out.println("list.additerator (99)"); list.additerator (99); system.out.print ("list. tostring():
" + list.tostring()); system.out.println("list.removeIterator()"); list.removerterator();
system.out.print ("list. tostring(): " + list.tostring()); system.out.println("list.offend(): " +
list.offend()); system.out.println("list. positionIterator()"); list. positionIterator();
system.out.println("list. removeIterator()"); list.removerterator();
system.out.println("list.offend(): " + list.offend()); system. out.print("list. tostring(): " +
list.tostring()); system.out.println("list. positionIterator()"); list.positioniterator();
system.out.println("list. advanceIterator ()"); list.advanceiterator();
system.out.println("list.advanceIterator ( ()"); list.advanceiterator(); system.out.println("list.
removeIterator()"); list. removerterator(); system.out.print("list. tostring(): " + list.tostring());

More Related Content

Similar to LabProgram.javaimport java.util.NoSuchElementException;public .pdf

In this lab, we will write an application to store a deck of cards i.pdf
In this lab, we will write an application to store a deck of cards i.pdfIn this lab, we will write an application to store a deck of cards i.pdf
In this lab, we will write an application to store a deck of cards i.pdf
contact41
 
The LinkedList1 class implements a Linked list. class.pdf
The LinkedList1 class implements a Linked list. class.pdfThe LinkedList1 class implements a Linked list. class.pdf
The LinkedList1 class implements a Linked list. class.pdf
malavshah9013
 
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdfLabprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
freddysarabia1
 
Please help me to make a programming project I have to sue them today- (1).pdf
Please help me to make a programming project I have to sue them today- (1).pdfPlease help me to make a programming project I have to sue them today- (1).pdf
Please help me to make a programming project I have to sue them today- (1).pdf
seoagam1
 
please read below it will tell you what we are using L.pdf
please read below it will tell you what we are using   L.pdfplease read below it will tell you what we are using   L.pdf
please read below it will tell you what we are using L.pdf
ankit11134
 
This assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdfThis assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdf
EricvtJFraserr
 
we using java code DynamicArrayjava Replace all .pdf
we using java code   DynamicArrayjava   Replace all .pdfwe using java code   DynamicArrayjava   Replace all .pdf
we using java code DynamicArrayjava Replace all .pdf
gudduraza28
 
package linkedLists- import java-util-Iterator- --- A class representi.pdf
package linkedLists- import java-util-Iterator- --- A class representi.pdfpackage linkedLists- import java-util-Iterator- --- A class representi.pdf
package linkedLists- import java-util-Iterator- --- A class representi.pdf
arcellzone
 
Please complete all the code as per instructions in Java programming.docx
Please complete all the code as per instructions in Java programming.docxPlease complete all the code as per instructions in Java programming.docx
Please complete all the code as per instructions in Java programming.docx
cgraciela1
 
How do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdfHow do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdf
feelinggift
 
Hi,I have added the methods and main class as per your requirement.pdf
Hi,I have added the methods and main class as per your requirement.pdfHi,I have added the methods and main class as per your requirement.pdf
Hi,I have added the methods and main class as per your requirement.pdf
annaelctronics
 
For this micro assignment, you must implement two Linked List functi.docx
For this micro assignment, you must implement two Linked List functi.docxFor this micro assignment, you must implement two Linked List functi.docx
For this micro assignment, you must implement two Linked List functi.docx
mckellarhastings
 
Please do parts labeled TODO LinkedList.java Replace.pdf
Please do parts labeled TODO LinkedList.java Replace.pdfPlease do parts labeled TODO LinkedList.java Replace.pdf
Please do parts labeled TODO LinkedList.java Replace.pdf
aioils
 
please read the steps below and it will tell you what we usi.pdf
please read the steps below and it will tell you what we usi.pdfplease read the steps below and it will tell you what we usi.pdf
please read the steps below and it will tell you what we usi.pdf
aggarwalopticalsco
 
Problem- Describe an algorithm for concatenating two singly linked lis.pdf
Problem- Describe an algorithm for concatenating two singly linked lis.pdfProblem- Describe an algorithm for concatenating two singly linked lis.pdf
Problem- Describe an algorithm for concatenating two singly linked lis.pdf
JamesPXNNewmanp
 
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
 
Exception to indicate that Singly LinkedList is empty. .pdf
  Exception to indicate that Singly LinkedList is empty. .pdf  Exception to indicate that Singly LinkedList is empty. .pdf
Exception to indicate that Singly LinkedList is empty. .pdf
aravlitraders2012
 
Describe an algorithm for concatenating two singly linked lists L and.pdf
Describe an algorithm for concatenating two singly linked lists L and.pdfDescribe an algorithm for concatenating two singly linked lists L and.pdf
Describe an algorithm for concatenating two singly linked lists L and.pdf
deepak596396
 
Use C++ Write a function to merge two doubly linked lists. The input.pdf
Use C++ Write a function to merge two doubly linked lists. The input.pdfUse C++ Write a function to merge two doubly linked lists. The input.pdf
Use C++ Write a function to merge two doubly linked lists. The input.pdf
shalins6
 
Problem- Describe an algorithm for concatenating two singly linked lis.pdf
Problem- Describe an algorithm for concatenating two singly linked lis.pdfProblem- Describe an algorithm for concatenating two singly linked lis.pdf
Problem- Describe an algorithm for concatenating two singly linked lis.pdf
kingsandqueens3
 

Similar to LabProgram.javaimport java.util.NoSuchElementException;public .pdf (20)

In this lab, we will write an application to store a deck of cards i.pdf
In this lab, we will write an application to store a deck of cards i.pdfIn this lab, we will write an application to store a deck of cards i.pdf
In this lab, we will write an application to store a deck of cards i.pdf
 
The LinkedList1 class implements a Linked list. class.pdf
The LinkedList1 class implements a Linked list. class.pdfThe LinkedList1 class implements a Linked list. class.pdf
The LinkedList1 class implements a Linked list. class.pdf
 
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdfLabprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
 
Please help me to make a programming project I have to sue them today- (1).pdf
Please help me to make a programming project I have to sue them today- (1).pdfPlease help me to make a programming project I have to sue them today- (1).pdf
Please help me to make a programming project I have to sue them today- (1).pdf
 
please read below it will tell you what we are using L.pdf
please read below it will tell you what we are using   L.pdfplease read below it will tell you what we are using   L.pdf
please read below it will tell you what we are using L.pdf
 
This assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdfThis assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdf
 
we using java code DynamicArrayjava Replace all .pdf
we using java code   DynamicArrayjava   Replace all .pdfwe using java code   DynamicArrayjava   Replace all .pdf
we using java code DynamicArrayjava Replace all .pdf
 
package linkedLists- import java-util-Iterator- --- A class representi.pdf
package linkedLists- import java-util-Iterator- --- A class representi.pdfpackage linkedLists- import java-util-Iterator- --- A class representi.pdf
package linkedLists- import java-util-Iterator- --- A class representi.pdf
 
Please complete all the code as per instructions in Java programming.docx
Please complete all the code as per instructions in Java programming.docxPlease complete all the code as per instructions in Java programming.docx
Please complete all the code as per instructions in Java programming.docx
 
How do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdfHow do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdf
 
Hi,I have added the methods and main class as per your requirement.pdf
Hi,I have added the methods and main class as per your requirement.pdfHi,I have added the methods and main class as per your requirement.pdf
Hi,I have added the methods and main class as per your requirement.pdf
 
For this micro assignment, you must implement two Linked List functi.docx
For this micro assignment, you must implement two Linked List functi.docxFor this micro assignment, you must implement two Linked List functi.docx
For this micro assignment, you must implement two Linked List functi.docx
 
Please do parts labeled TODO LinkedList.java Replace.pdf
Please do parts labeled TODO LinkedList.java Replace.pdfPlease do parts labeled TODO LinkedList.java Replace.pdf
Please do parts labeled TODO LinkedList.java Replace.pdf
 
please read the steps below and it will tell you what we usi.pdf
please read the steps below and it will tell you what we usi.pdfplease read the steps below and it will tell you what we usi.pdf
please read the steps below and it will tell you what we usi.pdf
 
Problem- Describe an algorithm for concatenating two singly linked lis.pdf
Problem- Describe an algorithm for concatenating two singly linked lis.pdfProblem- Describe an algorithm for concatenating two singly linked lis.pdf
Problem- Describe an algorithm for concatenating two singly linked lis.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
 
Exception to indicate that Singly LinkedList is empty. .pdf
  Exception to indicate that Singly LinkedList is empty. .pdf  Exception to indicate that Singly LinkedList is empty. .pdf
Exception to indicate that Singly LinkedList is empty. .pdf
 
Describe an algorithm for concatenating two singly linked lists L and.pdf
Describe an algorithm for concatenating two singly linked lists L and.pdfDescribe an algorithm for concatenating two singly linked lists L and.pdf
Describe an algorithm for concatenating two singly linked lists L and.pdf
 
Use C++ Write a function to merge two doubly linked lists. The input.pdf
Use C++ Write a function to merge two doubly linked lists. The input.pdfUse C++ Write a function to merge two doubly linked lists. The input.pdf
Use C++ Write a function to merge two doubly linked lists. The input.pdf
 
Problem- Describe an algorithm for concatenating two singly linked lis.pdf
Problem- Describe an algorithm for concatenating two singly linked lis.pdfProblem- Describe an algorithm for concatenating two singly linked lis.pdf
Problem- Describe an algorithm for concatenating two singly linked lis.pdf
 

More from fantasiatheoutofthef

Introduction Pervasive computing demands the all-encompassing exploi.pdf
Introduction Pervasive computing demands the all-encompassing exploi.pdfIntroduction Pervasive computing demands the all-encompassing exploi.pdf
Introduction Pervasive computing demands the all-encompassing exploi.pdf
fantasiatheoutofthef
 
International projects are on the rise, so the need for project mana.pdf
International projects are on the rise, so the need for project mana.pdfInternational projects are on the rise, so the need for project mana.pdf
International projects are on the rise, so the need for project mana.pdf
fantasiatheoutofthef
 
Instructions On July 1, a petty cash fund was established for $100. .pdf
Instructions On July 1, a petty cash fund was established for $100. .pdfInstructions On July 1, a petty cash fund was established for $100. .pdf
Instructions On July 1, a petty cash fund was established for $100. .pdf
fantasiatheoutofthef
 
Just C, D, E 7-1 Hoare partition correctness The version of PART.pdf
Just C, D, E 7-1 Hoare partition correctness The version of PART.pdfJust C, D, E 7-1 Hoare partition correctness The version of PART.pdf
Just C, D, E 7-1 Hoare partition correctness The version of PART.pdf
fantasiatheoutofthef
 
Integral ICreate a Python function for I-Importancedef monteca.pdf
Integral ICreate a Python function for I-Importancedef monteca.pdfIntegral ICreate a Python function for I-Importancedef monteca.pdf
Integral ICreate a Python function for I-Importancedef monteca.pdf
fantasiatheoutofthef
 
IntroductionThe capstone project is a �structured walkthrough� pen.pdf
IntroductionThe capstone project is a �structured walkthrough� pen.pdfIntroductionThe capstone project is a �structured walkthrough� pen.pdf
IntroductionThe capstone project is a �structured walkthrough� pen.pdf
fantasiatheoutofthef
 
Industry Solution Descartes for Ocean Carriers Customer Success Stor.pdf
Industry Solution Descartes for Ocean Carriers Customer Success Stor.pdfIndustry Solution Descartes for Ocean Carriers Customer Success Stor.pdf
Industry Solution Descartes for Ocean Carriers Customer Success Stor.pdf
fantasiatheoutofthef
 
Jefferson City has several capital projects that the mayor wants to .pdf
Jefferson City has several capital projects that the mayor wants to .pdfJefferson City has several capital projects that the mayor wants to .pdf
Jefferson City has several capital projects that the mayor wants to .pdf
fantasiatheoutofthef
 
Instructions Create an Android app according to the requirements below.pdf
Instructions Create an Android app according to the requirements below.pdfInstructions Create an Android app according to the requirements below.pdf
Instructions Create an Android app according to the requirements below.pdf
fantasiatheoutofthef
 
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
 
In this case study, we will explore the exercise of power in leaders.pdf
In this case study, we will explore the exercise of power in leaders.pdfIn this case study, we will explore the exercise of power in leaders.pdf
In this case study, we will explore the exercise of power in leaders.pdf
fantasiatheoutofthef
 
James Santelli was staying at a motel owned by Abu Rahmatullah for s.pdf
James Santelli was staying at a motel owned by Abu Rahmatullah for s.pdfJames Santelli was staying at a motel owned by Abu Rahmatullah for s.pdf
James Santelli was staying at a motel owned by Abu Rahmatullah for s.pdf
fantasiatheoutofthef
 
Ive already completed the Java assignment below, but it doesnt wor.pdf
Ive already completed the Java assignment below, but it doesnt wor.pdfIve already completed the Java assignment below, but it doesnt wor.pdf
Ive already completed the Java assignment below, but it doesnt wor.pdf
fantasiatheoutofthef
 
In this assignment you will implement insert() method for a singly l.pdf
In this assignment you will implement insert() method for a singly l.pdfIn this assignment you will implement insert() method for a singly l.pdf
In this assignment you will implement insert() method for a singly l.pdf
fantasiatheoutofthef
 
Introduction Pervasive computing demands the all-encompassing exploita.pdf
Introduction Pervasive computing demands the all-encompassing exploita.pdfIntroduction Pervasive computing demands the all-encompassing exploita.pdf
Introduction Pervasive computing demands the all-encompassing exploita.pdf
fantasiatheoutofthef
 
Introduction (1 Mark)Body (7 Marks)1-Definition of Technolog.pdf
Introduction (1 Mark)Body (7 Marks)1-Definition of Technolog.pdfIntroduction (1 Mark)Body (7 Marks)1-Definition of Technolog.pdf
Introduction (1 Mark)Body (7 Marks)1-Definition of Technolog.pdf
fantasiatheoutofthef
 
Integral IEstimator for Iwhere f(x) = 20 - x^2 and p(x) ~ U[a,.pdf
Integral IEstimator for Iwhere f(x) = 20 - x^2 and p(x) ~ U[a,.pdfIntegral IEstimator for Iwhere f(x) = 20 - x^2 and p(x) ~ U[a,.pdf
Integral IEstimator for Iwhere f(x) = 20 - x^2 and p(x) ~ U[a,.pdf
fantasiatheoutofthef
 
Indicate and provide a brief explanation for whether the following i.pdf
Indicate and provide a brief explanation for whether the following i.pdfIndicate and provide a brief explanation for whether the following i.pdf
Indicate and provide a brief explanation for whether the following i.pdf
fantasiatheoutofthef
 
Lindsay was leaving a local department store when an armed security .pdf
Lindsay was leaving a local department store when an armed security .pdfLindsay was leaving a local department store when an armed security .pdf
Lindsay was leaving a local department store when an armed security .pdf
fantasiatheoutofthef
 
Learning Team � Ethical Challenges Worksheet Your team of internat.pdf
Learning Team � Ethical Challenges Worksheet Your team of internat.pdfLearning Team � Ethical Challenges Worksheet Your team of internat.pdf
Learning Team � Ethical Challenges Worksheet Your team of internat.pdf
fantasiatheoutofthef
 

More from fantasiatheoutofthef (20)

Introduction Pervasive computing demands the all-encompassing exploi.pdf
Introduction Pervasive computing demands the all-encompassing exploi.pdfIntroduction Pervasive computing demands the all-encompassing exploi.pdf
Introduction Pervasive computing demands the all-encompassing exploi.pdf
 
International projects are on the rise, so the need for project mana.pdf
International projects are on the rise, so the need for project mana.pdfInternational projects are on the rise, so the need for project mana.pdf
International projects are on the rise, so the need for project mana.pdf
 
Instructions On July 1, a petty cash fund was established for $100. .pdf
Instructions On July 1, a petty cash fund was established for $100. .pdfInstructions On July 1, a petty cash fund was established for $100. .pdf
Instructions On July 1, a petty cash fund was established for $100. .pdf
 
Just C, D, E 7-1 Hoare partition correctness The version of PART.pdf
Just C, D, E 7-1 Hoare partition correctness The version of PART.pdfJust C, D, E 7-1 Hoare partition correctness The version of PART.pdf
Just C, D, E 7-1 Hoare partition correctness The version of PART.pdf
 
Integral ICreate a Python function for I-Importancedef monteca.pdf
Integral ICreate a Python function for I-Importancedef monteca.pdfIntegral ICreate a Python function for I-Importancedef monteca.pdf
Integral ICreate a Python function for I-Importancedef monteca.pdf
 
IntroductionThe capstone project is a �structured walkthrough� pen.pdf
IntroductionThe capstone project is a �structured walkthrough� pen.pdfIntroductionThe capstone project is a �structured walkthrough� pen.pdf
IntroductionThe capstone project is a �structured walkthrough� pen.pdf
 
Industry Solution Descartes for Ocean Carriers Customer Success Stor.pdf
Industry Solution Descartes for Ocean Carriers Customer Success Stor.pdfIndustry Solution Descartes for Ocean Carriers Customer Success Stor.pdf
Industry Solution Descartes for Ocean Carriers Customer Success Stor.pdf
 
Jefferson City has several capital projects that the mayor wants to .pdf
Jefferson City has several capital projects that the mayor wants to .pdfJefferson City has several capital projects that the mayor wants to .pdf
Jefferson City has several capital projects that the mayor wants to .pdf
 
Instructions Create an Android app according to the requirements below.pdf
Instructions Create an Android app according to the requirements below.pdfInstructions Create an Android app according to the requirements below.pdf
Instructions Create an Android app according to the requirements below.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
 
In this case study, we will explore the exercise of power in leaders.pdf
In this case study, we will explore the exercise of power in leaders.pdfIn this case study, we will explore the exercise of power in leaders.pdf
In this case study, we will explore the exercise of power in leaders.pdf
 
James Santelli was staying at a motel owned by Abu Rahmatullah for s.pdf
James Santelli was staying at a motel owned by Abu Rahmatullah for s.pdfJames Santelli was staying at a motel owned by Abu Rahmatullah for s.pdf
James Santelli was staying at a motel owned by Abu Rahmatullah for s.pdf
 
Ive already completed the Java assignment below, but it doesnt wor.pdf
Ive already completed the Java assignment below, but it doesnt wor.pdfIve already completed the Java assignment below, but it doesnt wor.pdf
Ive already completed the Java assignment below, but it doesnt wor.pdf
 
In this assignment you will implement insert() method for a singly l.pdf
In this assignment you will implement insert() method for a singly l.pdfIn this assignment you will implement insert() method for a singly l.pdf
In this assignment you will implement insert() method for a singly l.pdf
 
Introduction Pervasive computing demands the all-encompassing exploita.pdf
Introduction Pervasive computing demands the all-encompassing exploita.pdfIntroduction Pervasive computing demands the all-encompassing exploita.pdf
Introduction Pervasive computing demands the all-encompassing exploita.pdf
 
Introduction (1 Mark)Body (7 Marks)1-Definition of Technolog.pdf
Introduction (1 Mark)Body (7 Marks)1-Definition of Technolog.pdfIntroduction (1 Mark)Body (7 Marks)1-Definition of Technolog.pdf
Introduction (1 Mark)Body (7 Marks)1-Definition of Technolog.pdf
 
Integral IEstimator for Iwhere f(x) = 20 - x^2 and p(x) ~ U[a,.pdf
Integral IEstimator for Iwhere f(x) = 20 - x^2 and p(x) ~ U[a,.pdfIntegral IEstimator for Iwhere f(x) = 20 - x^2 and p(x) ~ U[a,.pdf
Integral IEstimator for Iwhere f(x) = 20 - x^2 and p(x) ~ U[a,.pdf
 
Indicate and provide a brief explanation for whether the following i.pdf
Indicate and provide a brief explanation for whether the following i.pdfIndicate and provide a brief explanation for whether the following i.pdf
Indicate and provide a brief explanation for whether the following i.pdf
 
Lindsay was leaving a local department store when an armed security .pdf
Lindsay was leaving a local department store when an armed security .pdfLindsay was leaving a local department store when an armed security .pdf
Lindsay was leaving a local department store when an armed security .pdf
 
Learning Team � Ethical Challenges Worksheet Your team of internat.pdf
Learning Team � Ethical Challenges Worksheet Your team of internat.pdfLearning Team � Ethical Challenges Worksheet Your team of internat.pdf
Learning Team � Ethical Challenges Worksheet Your team of internat.pdf
 

Recently uploaded

How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
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
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
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
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
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
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 

Recently uploaded (20)

How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
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 ...
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
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
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
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
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 

LabProgram.javaimport java.util.NoSuchElementException;public .pdf

  • 1. LabProgram.java import java.util.NoSuchElementException; public class LinkedList { private class Node { private T data; private Node next; private Node prev; public Node(T data) { this.data = data; this.next = null; this.prev = null; } } private int length; private Node first; private Node last; private Node iterator; /**** CONSTRUCTORS ****/ /** * Instantiates a new LinkedList with default values * @postcondition */ public LinkedList() { first = null; last = null; iterator = null; length = 0; } /** * Converts the given array into a LinkedList * @param array the array of values to insert into this LinkedList * @postcondition */
  • 2. public LinkedList(T[] array) { } /** * Instantiates a new LinkedList by copying another List * @param original the LinkedList to copy * @postcondition a new List object, which is an identical, * but separate, copy of the LinkedList original */ public LinkedList(LinkedList original) { } /**** ACCESSORS ****/ /** * Returns the value stored in the first node * @precondition <> * @return the value stored at node first * @throws NoSuchElementException <> */ public T getFirst() throws NoSuchElementException { if (isEmpty()){ throw new NoSuchElementException("The list is empty"); } return first.data; } /** * Returns the value stored in the last node * @precondition <> * @return the value stored in the node last * @throws NoSuchElementException <> */ public T getLast() throws NoSuchElementException { if (isEmpty()){ throw new NoSuchElementException("The list is empty");
  • 3. } return last.data; } /** * Returns the data stored in the iterator node * @precondition * @return the data stored in the iterator node * @throw NullPointerException */ public T getIterator() throws NullPointerException { return iterator.data; } /** * Returns the current length of the LinkedList * @return the length of the LinkedList from 0 to n */ public int getLength() { return length; } /** * Returns whether the LinkedList is currently empty * @return whether the LinkedList is empty */ public boolean isEmpty() { return length == 0; } /** * Returns whether the iterator is offEnd, i.e. null * @return whether the iterator is null */ public boolean offEnd() { return iterator == null; } /**** MUTATORS ****/ /** * Creates a new first element
  • 4. * @param data the data to insert at the front of the LinkedList * @postcondition <> */ public void addFirst(T data) { Node newNode = new Node(data); if(isEmpty()){ first = newNode; last = newNode; } else{ newNode.next = first; first.prev = newNode; first = newNode; } length++; } /** * Creates a new last element * @param data the data to insert at the end of the LinkedList * @postcondition <> */ public void addLast(T data) { Node newNode = new Node(data); if(isEmpty()){ first = newNode; last = newNode; } else{
  • 5. last.next = newNode; newNode.prev = last; last = newNode; } length++; } /** * Inserts a new element after the iterator * @param data the data to insert * @precondition * @throws NullPointerException */ public void addIterator(T data) throws NullPointerException{ return; } /** * removes the element at the front of the LinkedList */ public void removeFirst() throws NoSuchElementException { if(isEmpty()){ throw new NoSuchElementException("The list is empty"); } if(length == 1){ first = null; last = null; iterator = null; } else{ if(iterator == first){
  • 6. iterator = null; } first = first.next; first.prev = null; } length--; } /** * removes the element at the end of the LinkedList */ public void removeLast() throws NoSuchElementException { if(isEmpty()){ throw new NoSuchElementException("The list is empty"); } if(length == 1){ first = null; last = null; iterator = null; } else{ if(iterator == last){ iterator = null; } last = last.prev; last.next = null; } length--; } /** * removes the element referenced by the iterator * @precondition * @postcondition
  • 7. * @throws NullPointerException */ public void removeIterator() throws NullPointerException { } /** * places the iterator at the first node * @postcondition */ public void positionIterator(){ } /** * Moves the iterator one node towards the last * @precondition * @postcondition * @throws NullPointerException */ public void advanceIterator() throws NullPointerException { } /** * Moves the iterator one node towards the first * @precondition * @postcondition * @throws NullPointerException */ public void reverseIterator() throws NullPointerException { } /**** ADDITIONAL OPERATIONS ****/ /** * Re-sets LinkedList to empty as if the * default constructor had just been called */ public void clear() { first = null; last = null; iterator = null; length = 0;
  • 8. } /** * Converts the LinkedList to a String, with each value separated by a blank * line At the end of the String, place a new line character * @return the LinkedList as a String */ @Override public String toString() { StringBuilder result = new StringBuilder(); Node temp = first; while (temp != null){ result.append(temp.data + " "); temp = temp.next; } return result.toString() + "n"; } /** * Determines whether the given Object is * another LinkedList, containing * the same data in the same order * @param obj another Object * @return whether there is equality */ @SuppressWarnings("unchecked") //good practice to remove warning here @Override public boolean equals(Object obj) { return false; } /**CHALLENGE METHODS*/ /** * Moves all nodes in the list towards the end * of the list the number of times specified * Any node that falls off the end of the list as it
  • 9. * moves forward will be placed the front of the list * For example: [1, 2, 3, 4, 5], numMoves = 2 -> [4, 5, 1, 2 ,3] * For example: [1, 2, 3, 4, 5], numMoves = 4 -> [2, 3, 4, 5, 1] * For example: [1, 2, 3, 4, 5], numMoves = 7 -> [4, 5, 1, 2 ,3] * @param numMoves the number of times to move each node. * @precondition numMoves >= 0 * @postcondition iterator position unchanged (i.e. still referencing * the same node in the list, regardless of new location of Node) * @throws IllegalArgumentException when numMoves < 0 */ public void spinList(int numMoves) throws IllegalArgumentException{ } /** * Splices together two LinkedLists to create a third List * which contains alternating values from this list * and the given parameter * For example: [1,2,3] and [4,5,6] -> [1,4,2,5,3,6] * For example: [1, 2, 3, 4] and [5, 6] -> [1, 5, 2, 6, 3, 4] * For example: [1, 2] and [3, 4, 5, 6] -> [1, 3, 2, 4, 5, 6] * @param list the second LinkedList * @return a new LinkedList, which is the result of * interlocking this and list * @postcondition this and list are unchanged */ public LinkedList altLists(LinkedList list) { return null; } } Within your LinkedList class, see the field: private Node iterator; Notice that the iterator begins at null, as defined by the LinkedList constructors. Take a moment now to update your default constructor to set iterator = null; Also, look back at removefirst () and removeLast(). Consider now what will happen if the iterator is at the first or last Node when these methods are called. Update the methods to handle these edge cases now. We will develop additional methods during this lab to work with the iterator. Remember to fill in the pre-and postconditions for each method, as needed. Also inspect the LabProgram. java file and notice that the main () method of
  • 10. the LabProgram creates a list of numbers and inserts each into a list. The main() method then calls various iterator methods, displaying results of the method operation. Use Develop mode to test your Linked List iterator code as you develop it. In Submit mode you will need to complete all lab steps to pass all automatic tests. Step 2: Implement positionIterator() Method positionIterator() moves the iterator to the beginning of the list. public void positionIterator() // fill in here } public void positionIterator() ( // fill in here } Step 3: Implement offEnd() Method offEnd () returns whether the iterator is off the end of the list, i.e. set to null. Step 4: Implement getIterator() Method getIterator() returns the element in the Node where the iterator is currently located. Step 5: Implement advanceIterator() Method advanceIterator () moves the iterator forward by one node towards the last node. Step 6: Implement reverseIterator( ) Method reverseIterator () moves the iterator back by one node towards the first node. Step 7: Implement additerator() Method addIterator() inserts an element after the iterator. Step 8: Implement removeIterator() Method removeIterator () removes the Node currently referenced by the iterator and sets the iterator to null. t java.util.scanner; c class LabProgram { ublic static void main(string[] args) { LabProgram lab = new LabProgram(); // Make and display List LinkedList Integer list = new LinkedList >(); for (int i=1;i<4;i++){ list. addLast (i); } System.out.print("Created list: " + list.tostring()); // tostring() has system. out.println("list.offEnd(): " + list.offEnd()); system.out.println("list. positionIterator()"); list.positionIterator(); system.out.println("list.offend(): " + list.offEnd()); system.out.println("list.getiterator(): " + list.getiterator ()); list.advanceiterator(); System.out.println("list.getiterator (): " + list.getiterator ()); system.out.println("list.advanceIterator ( )n); list.advanceIterator(); System.out.println("list.getiterator(): " + list.getiterator()); system.out.println("list. reverseIterator ()n); list. reverseiterator(); System.out.println("list.getiterator(): " + list.getiterator()); system.out.println("list.additerator (42)"); list.addIterator (42); System.out.println("list.getiterator(): " + list.getiterator()); system.out.print "list. tostring(): " + list.tostring()); system.out.println("list.advanceIterator ( )n); list. advanceiterator(); system.out.println("list.advanceIterator ( )n); list.advanceiterator(); System.out.println("list.additerator (99)"); list.additerator (99); system.out.print ("list. tostring(): " + list.tostring()); system.out.println("list.removeIterator()"); list.removerterator(); system.out.print ("list. tostring(): " + list.tostring()); system.out.println("list.offend(): " + list.offend()); system.out.println("list. positionIterator()"); list. positionIterator(); system.out.println("list. removeIterator()"); list.removerterator(); system.out.println("list.offend(): " + list.offend()); system. out.print("list. tostring(): " + list.tostring()); system.out.println("list. positionIterator()"); list.positioniterator();
  • 11. system.out.println("list. advanceIterator ()"); list.advanceiterator(); system.out.println("list.advanceIterator ( ()"); list.advanceiterator(); system.out.println("list. removeIterator()"); list. removerterator(); system.out.print("list. tostring(): " + list.tostring());