Reference no: EM13165202
created a linkedlist class,the set() method and listiterator() method. I need someone to finish for me.
here is what i got so far:
import java.util.Iterator;
import java.util.ListIterator;
import java.util.NoSuchElementException;
public class MyLinkedList<Product> {
private Node<Product> head = null;
private Node<Product> tail = null;
private Node<Product> temp = null;
private int counter = 0;
public MyLinkedList() {
}
public int size(){return counter;}
public Product get(int position){
assert (position >= 0 && position < size());
temp = head;
for(int i = 0; i < position; i++) temp = temp.next;
return temp.element;
}
public void add(Product element) {
if (head == null) {
head = tail = new Node<Product>();
head.element = element;
head.next = tail;
tail = head;
}else{
tail.next = new Node<Product>();
tail = tail.next;
tail.element = element;
}
counter++;
}
/*public void set(int position, Product element) {
if (position == size()) {
add(element);
return;
} else if (position == 0) {
}
}*/
public void set(int inLayer, Product element) {
if (head == null) {
head = tail = new Node<Product>();
head.element = element;
head.next = tail;
tail = head;
}else{
tail.next = new Node<Product>();
tail = tail.next;
tail.element = element;
}
counter++;
}
public ListIterator<Product> iterator() {
return ListIterator<Product>();
}
Node<Product> current = head;
boolean hasNext() {
return (current.next != null);
}
Product next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
current = current.next;
return current.value;
}
What resources did you use in preparing this tax return
: What resources did you use in preparing this tax return? Provide references to page numbers in your textbook and specific addresses within the IRS website.
|
What is the compound empirical formula
: a 175.0g sample of a compound contains 56.15g C, 9.43g H, 74.81g O, 13.11g N, and 21.49g Na. What is the compound's empirical formula?
|
State how many moles of oxygen atoms
: 1. How many CO2 molecules are needed to produce 1 glucose molecule (in photosynthesis)? 2. How many moles of oxygen atoms are in 1 mole of calcium phosphate?
|
Calculate the mass of lycopene
: (a)how do I calculate the concentration of the lycopene solution in the spectrophotometer cell before isomerization, given that the molar absorptivity of lycopene at 471 nm is 1.86 x 10^4. (b) Calculate the mass of lycopene in 3.0mL of the solutio..
|
Created a linked list class
: created a linkedlist class
|
How many grams of naoh should we have used
: The molar mass of corn oil is 890g/mole. How many moles and how many grams of sodium hydroxide are required to react with the 15mL (13.7g) of corn oil? Show your calculations.
|
Develop an interface evaluation questionnaire
: Develop an interface evaluation questionnaire that contains 20 generic questions that would apply to most interfaces.
|
How many ozone molecules are in a liter
: If the pressure exerted by ozone, O3, in the stratosphere is 3.0*10^-3 atm and the temperature is 250 K, how many ozone molecules are in a liter?
|
Decomposition for r = (a,b,c,d,e )
: Give a good decomposition for R = (A,B,C,D,E ) with the following functional dependencies:
|