Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA I need an expert to edit on the code to make it works on online compiler and solve what inside the main in the

JAVA

I need an expert to edit on the code to make it works on online compiler and solve what inside the main in the comment:

interface MyQueue { public void enqueue(T element);

public T dequeue();

public T first(); public boolean isEmpty(); public int size();

public String toString();

} class MyLinkedListQueue implements MyQueue { MyLinkedList list = new MyLinkedList(); public void enqueue(T element) { list.addLast(new Node(element)); } public T dequeue() { if (isEmpty()) throw new QueueEmptyException("Queue is empty"); // remove element from the front of the list Node o = list.removeFirst(); return o.getElement(); }

public T first() { if (isEmpty()) return null; return list.first().getElement(); } public boolean isEmpty() { if (list.size()==0) return true; return false; }

public int size() { return list.size(); }

public String toString() { return "Queue"; }

} public class Main { public static void main(String[] args) { MyQueue queue = new MyLinkedListQueue();

queue.enqueue(34); queue.enqueue(56); queue.enqueue(12); queue.enqueue(8); queue.enqueue(44); queue.enqueue(12); queue.enqueue(45);

// a) Now dequeue the queue 3 times // b) Now insert 72 in the queue

//show the whole queue }

} }

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

Database Concepts

Authors: David Kroenke

4th Edition

0136086535, 9780136086536

More Books

Students also viewed these Databases questions

Question

1. Identify the sources for this conflict.

Answered: 1 week ago