Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm a beginner in JAVA Create a generic queue class, implementing it using a linked list . Define a generic node class inside the queue

I'm a beginner in JAVA

Create a generic queue class, implementing it using a linked list. Define a generic node class inside the queue class that will be made up of a data member of type T and a data member of the generic node type. The queue class will have three data members:

An object of the generic node class to store the reference to the first node in the queue

An object of the generic node class to store the reference to the last node in the queue

An integer to store the number of nodes in the queue

Code the following instance methods:

the zero-parameter constructor setting up an empty queue

public void addToQueue( T ) adds an element to the queue

public T deleteFromQueue( ) removes an element from the queue

public boolean isEmpty() returns true if the queue is empty and false otherwise

public int size() returns the number of elements in the queue

public T lookUp() returns the first element in the queue without deleting it

public void clearQueue() clears the queue ( reset it to be empty )

public String toString() creates a string with the content of the queue

Write your own small main method (in a separate file) to test your queue class thoroughly.

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_2

Step: 3

blur-text-image_step3

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