Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

these are the given information and I'm struggling with remove public class Queue { public int size; public String[] items; /** * initialize array to

these are the given information and I'm struggling with remove

public class Queue {

public int size;

public String[] items;

/**

* initialize array to an empty array and size to 0

*/

public Queue() {

size = 0;

items = new String[0];

}

/**

*

* @return the front item (and remove it) from the queue.

* return null if queue is empty.

*/

public String remove() {

code here

return ;

}

@@ test

class QueueTest {

Queue q1, q2, q3;

@BeforeEach

public void run() {

q1 = new Queue();

q2 = new Queue();

q3 = new Queue();

for(int i=0; i < 100; i++) {

q2.insert((i+1)+"");

}

for(int i=0; i < 1000; i++) {

q3.insert((i+1)*2+"");

}

}

public void testRemove() {

assertNull(q1.remove());

for(int i=0; i < 100; i++) {

String str = q2.remove();

assertNotNull(str);

assertEquals((i+1)+"", str);

}

assertNull(q2.remove());

for(int i=0; i < 1000; i++) {

String str = q3.remove();

assertNotNull(str);

assertEquals((i+1)*2+"", str);

}

assertNull(q3.remove());

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_2

Step: 3

blur-text-image_3

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

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions

Question

=+c) Complete the test and report your conclusion.

Answered: 1 week ago

Question

Are the loops considered As a cycle?

Answered: 1 week ago

Question

What are the role of supervisors ?

Answered: 1 week ago

Question

Describe the features you do not like and explain why.

Answered: 1 week ago