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
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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
