Question
Please give me all necessary screenshot and comments . (I use Eclipse) Thanks import java.lang.reflect.*; import com.abc.pp.fifo.*; /** * Implementation of {@link PPBoundedFifo} which uses
Please give me all necessary screenshot and comments. (I use Eclipse) Thanks
import java.lang.reflect.*;
import com.abc.pp.fifo.*;
/** * Implementation of {@link PPBoundedFifo} which uses a circular array * internally. *
* Look at the documentation in PPBoundedFifo to see how the methods are * supposed to work. *
* The data is stored in the slots array. count is the number of items currently * in the FIFO. When the FIFO is not empty, head is the index of the next item * to remove. When the FIFO is not full, tail is the index of the next available * slot to use for an added item. Both head and tail need to jump to index 0 * when they "increment" past the last valid index of slots (this is what makes * it circular). *
* See Circular Buffer * on Wikipedia for more information. */ public class CircularArrayPPBoundedFifo
public CircularArrayPPBoundedFifo(int fixedCapacity, Class
lockObject = proposedLockObject != null ? proposedLockObject : new Object();
if ( fixedCapacity < 1 ) { throw new IllegalArgumentException( "fixedCapacity must be at least 1"); }
if (itemType == null) { throw new IllegalArgumentException("itemType must not be null"); } this.itemType = itemType;
slots = createTypeArray(fixedCapacity); head = 0; tail = 0; count = 0;
// TODO - add more to constructor if you need to....but don't change code above this line }
// this constructor is correct as written - do not change public CircularArrayPPBoundedFifo(int fixedCapacity, Class
@SuppressWarnings("unchecked") private T[] createTypeArray(int size) { T[] array = (T[]) Array.newInstance(itemType, size); return array; }
// this method is correct as written - do not change @Override public int getCount() { synchronized ( lockObject ) { return count; } }
@Override public boolean isEmpty() { // FIXME return false; }
@Override public boolean isFull() { // FIXME return false; }
@Override public void clear() { // FIXME }
// this method is correct as written - do not change @Override public int getCapacity() { return slots.length; }
@Override public void add(T item) throws InterruptedException { // FIXME }
@Override public T remove() throws InterruptedException { // FIXME return null; }
// this method is correct as written - do not change @Override public Object getLockObject() { return lockObject; }
// this method is correct as written - do not change @Override public Class
@Override public void addAll(T[] items) throws InterruptedException { // FIXME }
@Override public T[] removeAtLeastOne() throws InterruptedException { // FIXME return null; }
@Override public T[] removeAll() { // FIXME return null; }
@Override public boolean waitUntilEmpty(long msTimeout) throws InterruptedException { // FIXME return false; }
// this method is correct as written - do not change @Override public void waitUntilEmpty() throws InterruptedException { waitUntilEmpty(0); }
@Override public boolean waitWhileEmpty(long msTimeout) throws InterruptedException { // FIXME return false; }
@Override public void waitWhileEmpty() throws InterruptedException { // FIXME }
@Override public boolean waitUntilFull(long msTimeout) throws InterruptedException { // FIXME return false; }
@Override public void waitUntilFull() throws InterruptedException { // FIXME }
@Override public boolean waitWhileFull(long msTimeout) throws InterruptedException { // FIXME return false; }
@Override public void waitWhileFull() throws InterruptedException { // FIXME } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started