Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi Dear ! I want to write a JUnit test for the class LinkedQueue : could you please help me. import java.util.Iterator; public class LinkedQueue

Hi Dear !

I want to write a JUnit test for the class LinkedQueue :

could you please help me.

import java.util.Iterator;

public class LinkedQueue implements IntQueue { private int queueArr[]; // size of array in the queue private int first; private int last; private int power; // capacity private int size; // size of the queue

LinkedQueue(int size) { queueArr = new int[size]; power = size; first = 0; last = -1; size = 0; }

@Override public Iterator iterator() {

return null; }

@Override public int size() { return size; }

@Override public boolean isEmpty() { return (size() == 0); }

public boolean isFull() { return (size() == power);

}

@Override public void enqueue(int element) {

if (isFull()) { System.out.println("The Queue is full Program Terminated"); System.exit(1); }

System.out.println("Enter " + element);

last = (last + 1) % power; queueArr[last] = element; size++;

}

@Override public int dequeue() {

if (isEmpty()) { System.out.println("Queue is empty. No element to dequeue Program Terminated"); System.exit(1); }

System.out.println("removing " + queueArr[first]); int dequeuedElement = queueArr[first];

first = (first + 1) % power; size--;

return dequeuedElement; }

@Override public int first() {

return queueArr[first]; }

@Override public int last() {

return queueArr[last];

}

@Override public String toString() {

String queueContent = new String();

for (int i = 0; i < size(); i++) queueContent += (" " + queueArr[i] + " ");

return queueContent;

}

}

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

Big Data And Hadoop Fundamentals Tools And Techniques For Data Driven Success

Authors: Mayank Bhushan

2nd Edition

9355516665, 978-9355516664

More Books

Students also viewed these Databases questions