Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public Fish removeFirst ( ) Remove and return the first Fish in the doubly linked - list. Return null if the list is empty. public

public Fish removeFirst()
Remove and return the first Fish in the doubly linked-list. Return null if the list is empty.
public Fish removeLast()
Remove and return the last Fish in the doubly linked-list. Return null if the list is empty.
public Fish remove(int index)
Remove and return the Fish at the specified "index". Return null if the index is beyond
the end of the doubly linked-list or if the list is empty.
public Fish get(int index)
Return (but do not remove) the Fish at the specified "index". Return null if the index is
beyond the end of the doubly linked-list or if the list is empty. Double Linked-Lists (100 pts)
A) Doubly Linked-List (double linked-list code can be found in the "Assignment5_C" IntelliJ project).
Your task for Part A is to fully implement the "FishLinkedList" class. The FishLinkedList class is a
doubly linked-list that holds Fish objects. The start of the doubly linked-list is "head", the end is
"tail".
The fixed stack methods that need to be implemented are as follows:
private boolean contains(Fish fish)
Returns true if the Fish parameter "fish" is already in the doubly linked-list, false if not.
public boolean addFirst(Fish fish)
Adds the Fish parameter "fish" to the beginning of the linked list unless that fish is already
in the doubly linked-list. Return true if the Fish is added, false if the Fish was not added
because it is already in the list.
public boolean addLast(Fish fish)
Adds the Fish parameter "fish" to the end of the linked list unless that fish is already in
the doubly linked-list. Return true if the Fish is added, false if the Fish was not added
because it is already in the list.
public boolean add(int index, Fish fish)
Adds the Fish parameter "fish" to the linked list at the specified "index", unless that index
is beyond the end of the doubly linked-list or that fish is already in the doubly linked-list.
Return true if the Fish is added, false if the index is beyond the end of the doubly linked-
list or if it is already in the list.
public Fish removeFirst()
Remove and return the first Fish in the doubly linked-list. Return null if the list is empty.
public Fish removeLast()
Remove and return the last Fish in the doubly linked-list. Return null if the list is empty.
public Fish remove(int index)
Remove and return the Fish at the specified "index". Return null if the index is beyond
the end of the doubly linked-list or if the list is empty.
public Fish get(int index)
Return (but do not remove) the Fish at the specified "index". Return null if the index is
beyond the end of the doubly linked-list or if the list is empty.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions