Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

package Lab8; public interface QueueInterface { public boolean isEmpty(); public void enqueue(Object obj); public Object dequeue(); public void dequeueAll(); public Object peek(); } package Lab8;

image text in transcribed

package Lab8;

public interface QueueInterface {

public boolean isEmpty();

public void enqueue(Object obj);

public Object dequeue();

public void dequeueAll();

public Object peek();

}

package Lab8;

import java.util.Arrays;

import java.util.Stack;

/**

*

* @author

*/

public class Queue implements QueueInterface {

Stack stack1;

Stack stack2;

public Queue(){

stack1=new Stack();

stack2=new Stack();

}

@Override

public void enqueue(Object data){

}

@Override

public Object dequeue(){

}

@Override

public boolean isEmpty(){

}

@Override

public void dequeueAll(){

}

@Override

public Object peek(){

}

//display all items in the queue:

public void display(){

}

}

package Lab8;

public class QueueTest {

public static void main(String[] args){

Queue q=new Queue();

//add 10 customers to the queue and show the items of the queue

e.g., q.enqueue("Maria");

//dequeue three times and show the items of the queue

//dequeue all and show the items of the queue

}

}

Implement A Queue using Two Stacks Instructions: A) Goal: To gain experience with the Queue Data Structure B) Task: 1. Implement the interface of queue 2. Implement the display() method to display all items in the queue. 3. Add ten customers to the queue and show this queue. 4. Dequeue three times and show the queue. 5. Dequeue all and show the queue.. Hints: when you perform enqueue operation 1. Move all items from stack1 to stack2 2. Move newltem to stack1 3. Move all items back from stack2 to stack1 When you perform dequeue operation 1. pop stack1 C) Procedure 1. Download the attached classes and interfaces 2. Implement the queue interface 3. Test your codes 4

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

Microsoft Visual Basic 2008 Comprehensive Concepts And Techniques

Authors: Gary B. Shelly, Corinne Hoisington

1st Edition

1423927168, 978-1423927167

More Books

Students also viewed these Databases questions