Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

WILL UPVOTE ONLY RESPONSES THAT SATISFIES ONLY THESE CASES: HERE IS THE BLOCKS AND PARTITIONS: Whether queue is empty. a1:true (Value queue = []) a2:false

WILL UPVOTE ONLY RESPONSES THAT SATISFIES ONLY THESE CASES:

HERE IS THE BLOCKS AND PARTITIONS:

Whether queue is empty.

a1:true (Value queue = [])

a2:false (Value queue = [cat, hat]) Base

Whether queue is full.

b1:true (Value queue = [cat], cap = 1)

b2:false (Value queue = [cat, hat], cap = 3) Base

Size of queue.

c1:0 (Value queue = [])

c2:1 (Value queue = [cat], )

c3:more than 1 (Values queue = [cat, hat]) Base

Value of cap.

d1:negative (Value cap = -1) (May not be possible.)

d2:0 (Value cap = 0) (Also may not be possible.)

d3:1 (Value cap = 1 )

d4:more than 1 (Value cap = 2) Base

Value of capacity. (Note that this may differ from cap)

e1:negative (Value cap = -1)

e2:0 (Value cap = 0)

e3:1 (Value cap = 1 )

e4:more than 1 (Value cap = 2) Base Whether x is null.

f1:true (Value x = null)

f2:false (Value x = cat ) Base

well suppose we are testing Enqueue, since it makes the parameter x relevant. Note that the variable capacity in the constructor is not relevant to this set of tests, although the constructor will certainly be called in the setup for the given tests. That means well skip blocks e1, e2, e3, and e4 when defining the base choice tests for Enqueue.

The base test is (a2, b2, c3, d4, f2). Varying each partition gives 8 more tests:

{(a1, b2, c3, d4, f2),

(a2, b1, c3, d4, f2),

(a2, b2, c1, d4, f2),

(a2, b2, c2, d4, f2),

(a2, b2, c3, d1, f2), (

a2, b2, c3, d2, f2),

(a2, b2, c3, d3, f2),

(a2, b2, c3, d4, f1) }.

To see what one of these tests would look like, consider (a2, b2, c3, d3, f2), where the focus is on varying di , the value of cap. Note that the value for queue specified by c3 is incompatible with this choice. Further either a2 or b2 has to change, since, if cap is 1, the queue will always be either empty or full. Hence, a feasible variant of this test is (a2, b1, c2, d3, f2). To instantiate this test, it is clear that we need another value for a2, namely a one element value for queue, such as [cat]. To run this test, the test engineer would construct a queue (via q = new BoundedQueue(1);, insert a value (via q.enQueue("cat"); to achieve the desired start for the beginning of the test, and then carry out the test (via another call to q.enQueue("cat");. Naturally, the test engineer would want to verify that the resulting queue contained two cats. At this stage, the test engineer might decide that having two cats was not as informative as having, perhaps, a cat and a dog, thereby motivating an expansion of the possible values for block f2 to include dog.

HERE IS THE BASE CLASS:

package edu.kennesaw.seclass.BoundedQueue; public class BoundedQueue { // Overview: a BoundedQueue is a mutable, bounded FIFO data structure // of fixed size , with size being set in the constructor // A typical Queue is [], [o1], or [o1, o2], where neither o1 nor o2 // are ever null. Older elements are listed before newer ones. private final Object[] elements; private int size, front, back; private final int capacity; public BoundedQueue (int capacity) { if (capacity < 0) throw new IllegalArgumentException ("BoundedQueue.constructor"); this.capacity = capacity; elements = new Object [capacity]; size = 0; front = 0; back = 0; } public void enQueue (Object o) throws NullPointerException, IllegalStateException { // Modifies: this // Effects: If argument is null throw NullPointerException // else if this is full, throw IllegalStateException, // else make o the newest element of this if (o == null) throw new NullPointerException ("BoundedQueue.enQueue"); else if (size == capacity) throw new IllegalStateException ("BoundedQueue.enQueue"); else { size++; elements [back] = o; back = (back+1) % capacity; } } public Object deQueue () throws IllegalStateException { // Modifies: this // Effects: If queue is empty, throw IllegalStateException, // else remove and return oldest element of this if (size == 0) throw new IllegalStateException ("BoundedQueue.deQueue"); else { size--; Object o = elements [ (front % capacity) ]; elements [front] = null; front = (front+1) % capacity; return o; } } public boolean isEmpty() { return (size == 0); } public boolean isFull() { return (size == capacity); } } 

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

Students also viewed these Databases questions

Question

1.4 Graphs to Describe Time-Series Data

Answered: 1 week ago

Question

1.The difference between climate and weather?

Answered: 1 week ago

Question

1. What is Fog ?

Answered: 1 week ago

Question

How water vapour forms ?

Answered: 1 week ago

Question

What is Entrepreneur?

Answered: 1 week ago

Question

Which period is known as the chalolithic age ?

Answered: 1 week ago