Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write code (in the main method) that tests all of the methods of the following class: (I have attached a picture of the interface that

Write code (in the main method) that tests all of the methods of the following class: (I have attached a picture of the interface that it implements)image text in transcribed

import java.util.NoSuchElementException; public class QueueImpl implements QueueInterface { private Node first; // beginning of queue private Node last; // end of queue private int n; // number of elements in queue private final int max = 100; // maximum number of elements in queue // helper linked list class private static class Node { private Object item; private Node next; } public static void main(String[] args){ } /*initializes an empty queue * */ public QueueImpl() { first = null; last = null; n = 0; } /*returns true if this queue is empty * */ public boolean isEmpty() { return first == null; } /*returns the number of items in this queue * */ public int size() { return n; } @Override public void enqueue(Object newEntry) { if( n public interface Queuelnterface Adds a new entry to the back of this queue. @param newEntry An object to be added. public void enqueuem newEntry): Removes and returns the entry at the front of this queue. @return The object at the front of the queue. @throws Empty ueueException if the queue is empty before the operation. public T dequeue0; Retrieves the entry at the front of this queue. @return The object at the front of the queue. @throws E ueueException if the queue is empty. mptyQ public T getFront0: Detects whether this queue is empty. @return True if the queue is empty, or false otherwise. public boolean isEmpty(), Removes all entries from this queue. public void clearo generates a string containing all data in the queue and returns it public String toString0; end Queuelnterface

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: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases And Python Programming MySQL MongoDB OOP And Tkinter

Authors: R. PANNEERSELVAM

1st Edition

9357011331, 978-9357011334

More Books

Students also viewed these Databases questions