Answered step by step
Verified Expert Solution
Question
1 Approved Answer
in java. There should be 2 classes Main and MyQueue and interface QueueInterface Lab 6 - Chapter 7 Queue Implementation 2/27/2023 1. Using the java.util.LinkedList
in java. There should be 2 classes Main and MyQueue and interface QueueInterface
Lab 6 - Chapter 7 Queue Implementation 2/27/2023 1. Using the java.util.LinkedList class, define a class MyQueue that implements the following QueueInterface. public interface QueueInterface f / Adds a new entry to the back of this queue. / public void enqueue (T newEntry); / Removes and returns the entry at the front of this queue. */ public T dequeue () ; / Retrieves the entry at the front of this queue. */ public T getFront (); / Detects whether this queue is empty. */ public boolean isEmpty(); / Removes all entries from this queue. */ public void clear(); \} // end QueueInterface import java.util.LinkedList; public class MyQueue T implements QueueInterface T{ private LinkedList T list = new LinkedList T(); Qoverride public void enqueue (T newEntry) \{ list. addLast (newEntry) ; \} Qoverride public T dequeue () \{ return list.removeFirst(); \} eoverride public T getfront () 1 return list.getFirst(); \} Qoverride public boolean isEmpty() 1 return list.isEmpty() ; \} Qoverride public void clear() \{ list.clear (); \} \} 1 Write java tester code to find the contents of the myQueue after the following statements are completed and executed. By midnight, Tuesday, February 28th, submit your Java source file (Main.Java) and a screenshot of the execution result via 'Lab6 - Ch7 Queue' under the 'Submit Lab Assignments' menu in the course Blackboard. At the beginning of the code, add a heading with your name, the date submitted, a brief description of the assignment, and appropriate comments in the body. Lab 6 - Chapter 7 Queue Implementation 2/27/2023 1. Using the java.util.LinkedList class, define a class MyQueue that implements the following QueueInterface. public interface QueueInterface f / Adds a new entry to the back of this queue. / public void enqueue (T newEntry); / Removes and returns the entry at the front of this queue. */ public T dequeue () ; / Retrieves the entry at the front of this queue. */ public T getFront (); / Detects whether this queue is empty. */ public boolean isEmpty(); / Removes all entries from this queue. */ public void clear(); \} // end QueueInterface import java.util.LinkedList; public class MyQueue T implements QueueInterface T{ private LinkedList T list = new LinkedList T(); Qoverride public void enqueue (T newEntry) \{ list. addLast (newEntry) ; \} Qoverride public T dequeue () \{ return list.removeFirst(); \} eoverride public T getfront () 1 return list.getFirst(); \} Qoverride public boolean isEmpty() 1 return list.isEmpty() ; \} Qoverride public void clear() \{ list.clear (); \} \} 1 Write java tester code to find the contents of the myQueue after the following statements are completed and executed. By midnight, Tuesday, February 28th, submit your Java source file (Main.Java) and a screenshot of the execution result via 'Lab6 - Ch7 Queue' under the 'Submit Lab Assignments' menu in the course Blackboard. At the beginning of the code, add a heading with your name, the date submitted, a brief description of the assignment, and appropriate comments in the bodyStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started