In Java, Question 15: Answer the following questions You are asked to Implement an ADT for MyQueue. The following is a class definition of a linked list Node: class Node {     String content;     Node next; }   The following is a class definition of a linked list MyQueue:   class MyQueue {     Node head; }   Implement the following methods for your class MyQueue. a)  Constructor that does not requre any parameters  b)  Constructor that accepts a parameter of type MyQueue and creates a new instance of MyQueue that is a clone of the one passed as parameter c)  public int AppendCopy method that accepts a single parameter of type MyQueue and clones all elements from the MyQueue instance passed as a parameter and appends them to the instance on which we called the method. Return the number of elements that are cloned and appended  d) public int FindElements(String filter) - finds all elements that match the filter and returns their count  e) overload the FindElementsmethod to include a bolean flag whether to remove all matching elements from the queue. If the flag is true, remove the elements from the queue. Give the flag parameter a meaningful name  f) public void addToEnd() - add a node to the rear of the queue  g) overload addToEnd method to include a value for the content of the newly created node.  h) public Node removeFromFront() - remove an element from the front of the queue  Hint:  Some of the methods have overlapping functionality. Feel free to create utility methods and/or to work on these methods in a different order than what is given below and then reference the methods you already created in other steps. E.g., you may decide to implement AppendCopy and use it in another method.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter18: Stacks And Queues
Section: Chapter Questions
Problem 16PE: The implementation of a queue in an array, as given in this chapter, uses the variable count to...
icon
Related questions
Question

In Java,

Question 15: Answer the following questions

You are asked to Implement an ADT for MyQueue.

The following is a class definition of a linked list Node:

class Node

{

    String content;

    Node next;

}

 

The following is a class definition of a linked list MyQueue:

 

class MyQueue

{

    Node head;

}

 

Implement the following methods for your class MyQueue.

a)  Constructor that does not requre any parameters 

b)  Constructor that accepts a parameter of type MyQueue and creates a new instance of MyQueue that is a clone of the one passed as parameter

c)  public int AppendCopy method that accepts a single parameter of type MyQueue and clones all elements from the MyQueue instance passed as a parameter and appends them to the instance on which we called the method. Return the number of elements that are cloned and appended 

d) public int FindElements(String filter) - finds all elements that match the filter and returns their count 

e) overload the FindElementsmethod to include a bolean flag whether to remove all matching elements from the queue. If the flag is true, remove the elements from the queue. Give the flag parameter a meaningful name 

f) public void addToEnd() - add a node to the rear of the queue 

g) overload addToEnd method to include a value for the content of the newly created node. 

h) public Node removeFromFront() - remove an element from the front of the queue 

Hint:  Some of the methods have overlapping functionality. Feel free to create utility methods and/or to work on these methods in a different order than what is given below and then reference the methods you already created in other steps. E.g., you may decide to implement AppendCopy and use it in another method.

 

Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Generic Type
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning