Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement a value-pass to the following: import java.util.ArrayList; public class BufferTest implements Buffering { private static final int EXAMPLE = 5; public ArrayList EXAMPLE1; private

Implement a value-pass to the following:

import java.util.ArrayList;

public class BufferTest implements Buffering {

private static final int EXAMPLE = 5;

public ArrayList EXAMPLE1;

private int in, out, count;

public BufferTest() {

count = 0;

in = 0;

out = 0;

EXAMPLE1 = new ArrayList<>(EXAMPLE);

}

public void insert(String item) {

while (count == EXAMPLE)

; // do nothing -- no free space

// add an element to the buffer

EXAMPLE1.add(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.get(out);

out = (out + 1) % EXAMPLE;

--count;

return item;

}

}

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

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

9th Edition

0135188148, 978-0135188149, 9781642087611

More Books

Students also viewed these Databases questions

Question

Know when firms should not offer service guarantees.

Answered: 1 week ago

Question

Recognize the power of service guarantees.

Answered: 1 week ago