Question: Language is java. and LinkedQueue class is given below. package jsjf; import jsjf.exceptions.*; // LinkedQueue represents a linked implementation of a queue. public class LinkedQueue

 "Language is java. and LinkedQueue class is given below." package jsjf;

"Language is java. and LinkedQueue class is given below."

package jsjf;

import jsjf.exceptions.*;

// LinkedQueue represents a linked implementation of a queue.

public class LinkedQueue implements QueueADT

{

private int count;

private LinearNode head, tail;

// Creates an empty queue.

public LinkedQueue()

{

count = 0;

head = tail = null;

}

// Adds the specified element to the tail of this queue.

public void enqueue(T element)

{

LinearNode node = new LinearNode(element);

if (isEmpty())

head = node;

else

tail.setNext(node);

tail = node;

count++;

}

/ * Removes the element at the head of this queue and returns a

* reference to it.

*/

public T dequeue() throws EmptyCollectionException

{

if (isEmpty())

throw new EmptyCollectionException("queue");

T result = head.getElement();

head = head.getNext();

count--;

if (isEmpty())

tail = null;

return result;

}

(Sorry for not clearing it properly. i need LinkedOrderedQueue, Book class and Test data. i hope it clears you)

thank you.

Note: This will take a lot of time to code and get running because there are a number of classes involved. Give yourself lots of time to complete this. The purpose of this assignment is to organize the inventory of books in a library according to the year published. The books will be stored in a special type of linked queue where the oldest book with be at the front of the queue, the next oldest appears after it, and so on. The books must be added to the queue in random order. The queue you will build can hold any type of data we wish to order, books, employees, etc. Create a LinkedOrderedQueue class that inherits from the LinkedQueue class from Chapter 14 (you'll need to provide the code for the missing methods first). The LinkedOrderedQueue class implements enqueue differently (that is, it overrides the enqueue method). Also since the LinkedQueue class is now being used in inheritance, make it's instance variables protected so the child class can access them. Remove all references to package jsjf in the classes. In the LinkedOrderedQueue class the generic type parameter declaration will need to change to "T extends Comparable". Why? (because the way we determine the order of the nodes in the ordered queue is via the compareTo method from the Comparable interface) Also include a remove method in your LinkedOrderedQueue class. This method should receive a generic parameter, T, and uses the equals method to match this parameter with the node in the ordered queue that contains the information we are searching for (in this case it will be the book's title). You'll also need to create a Book class, that implements Comparable, and holds the book's title and the year published. The compare To method will use the year published to determine The Book class will also need to implement the equals method, for use in the remove code, and should use the book's title as the basis for the comparison (since the title is a String, use the equals method from the String class). A title is removed from the ordered queue because the library will no longer carry that book. Use the code for the equals(Object) method inherited from the Object class given below. Test your LinkedOrderedQueue class by adding Book objects according to their year published (oldest book appears first in the queue). Be sure to add the objects in random order by their year published. Print out the queue after you've added 8 books. Then try removing a few books, and adding a few more. Print out the final queue. What would be good test data for the enqueue, dequeue and remove operations? Note: This will take a lot of time to code and get running because there are a number of classes involved. Give yourself lots of time to complete this. The purpose of this assignment is to organize the inventory of books in a library according to the year published. The books will be stored in a special type of linked queue where the oldest book with be at the front of the queue, the next oldest appears after it, and so on. The books must be added to the queue in random order. The queue you will build can hold any type of data we wish to order, books, employees, etc. Create a LinkedOrderedQueue class that inherits from the LinkedQueue class from Chapter 14 (you'll need to provide the code for the missing methods first). The LinkedOrderedQueue class implements enqueue differently (that is, it overrides the enqueue method). Also since the LinkedQueue class is now being used in inheritance, make it's instance variables protected so the child class can access them. Remove all references to package jsjf in the classes. In the LinkedOrderedQueue class the generic type parameter declaration will need to change to "T extends Comparable". Why? (because the way we determine the order of the nodes in the ordered queue is via the compareTo method from the Comparable interface) Also include a remove method in your LinkedOrderedQueue class. This method should receive a generic parameter, T, and uses the equals method to match this parameter with the node in the ordered queue that contains the information we are searching for (in this case it will be the book's title). You'll also need to create a Book class, that implements Comparable, and holds the book's title and the year published. The compare To method will use the year published to determine The Book class will also need to implement the equals method, for use in the remove code, and should use the book's title as the basis for the comparison (since the title is a String, use the equals method from the String class). A title is removed from the ordered queue because the library will no longer carry that book. Use the code for the equals(Object) method inherited from the Object class given below. Test your LinkedOrderedQueue class by adding Book objects according to their year published (oldest book appears first in the queue). Be sure to add the objects in random order by their year published. Print out the queue after you've added 8 books. Then try removing a few books, and adding a few more. Print out the final queue. What would be good test data for the enqueue, dequeue and remove operations

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 Databases Questions!