Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is a homework assignment that has to be done in JAVA. Objective: Write a class Called GenDoubleLinkedList which is a generic double linked list.

This is a homework assignment that has to be done in JAVA.

Objective:

Write a class Called GenDoubleLinkedList which is a generic double linked list. This link list is similar to the single linked list that was shown in class except that each node in addition to having data and nextLink (which was originally called link) now has prevLink.

image text in transcribed

The class GenDoubleLinkedList needs to have the following:

-Internal class ListNode which has:

- Instance Variables:

- data of type T

- nextLink of type ListNode

- prevLink of type ListNode

- Constructors:

- Default

- Parameterized

Instance Variables:

- head of type ListNode which always points to the beginning of the linked list

- current of type ListNode which moves around pointing to one of the nodes

Constructor:

- A default constructor that initializes head to an empty ListNode and sets current to point at the head.

Methods:

- goToNext This moves the current node forward in the list by one node. It doesnt move forward if that node is null

- goToPrev This moves the current node backwards in the list by one node. It doesnt move backwards if that node is null.

- getDataAtCurrent returns the data at the current node as long as the current isnt null

- setDataAtCurrent takes in a parameter and sets the data at the current node to that value as long as current is not null

- insertNodeAfterCurrent creates a new node based on data that is passed in by a parameter and puts that node after the current position

- deleteCurrentNode removes the current node from the list by resetting the links

- showList prints out the contents of the list line-by-line

- inList returns a true or false value based on whether or not the data passed in via a parameter is in the list

Insert Node After Current

image text in transcribed

Delete Current Node

image text in transcribedFinally write a driver that demonstrates each of the methods is working with a double linked list of integers and strings.

Head Current

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual Basic Net Database Programming

Authors: Rod Stephens

1st Edition

0789726815, 978-0789726810

More Books

Students also viewed these Databases questions