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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education