Question: Implement ArrayList for this to work properly. BufferTest.java public class BufferTest { private static final int EXAMPLE = 5; public ArrayList EXAMPLE1; private int in,

Implement ArrayList for this to work properly.

BufferTest.java

public class BufferTest {

private static final int EXAMPLE = 5; public ArrayList EXAMPLE1; private int in, out, count;

public BufferImpl() { count = 0; in = 0; out = 0; EXAMPLE1 = new Integer[EXAMPLE]; } public void insert(String item) { while (count == EXAMPLE) ; // do nothing -- no free space

// add an element to the buffer //EXAMPLE1[in] = item; in = (in + 1) % EXAMPLE; ++count; } // consumers call this method public String remove() { String item; while (count == 0) ; // do nothing - nothing to consume

// removes from the buffer //item = EXAMPLE1[out]; out = (out + 1) % EXAMPLE; --count; return item; } }

Buffering.java

public interface Buffering { public void insert(E item); public E remove(); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!