Question: Create a class called ListOfItems that extends AbstractItems. This new class will use the Node created previously. The class will need three instance variables: a

Create a class called ListOfItems
that extends AbstractItems. This
new class will use the Node created
previously. The class will need
three instance variables:
a. A Node called head.
b. A Node called tail.
c. An int called size.
When a ListOfItems is created,
create a new Node and set both the
head and the tail to refer to it.
The first time that the "add" method
is called, add the Object to the
head node and increment size
from 0 to 1 Each time add is called
after that, follow this algorithm:
a. Create a new Node.
b. Add the Object to the new
Node. using the setItem
method.
c. Use the setNext mutator on
the current tail to point to
the new Node.
d. Change the tail to point to
the new Node.
e. Increment size.
Also provide an implementation for
the get method. This will require
you to start at the head and use the
getNext method to count the
appropriate number of nodes in the
list before returning the item at the
specified index using its getItem
method.
Create a class called ListOfItems that extends

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!