Complete the provided fixed size array-based CircularBuffer class by altering and or adding the following functionality:
void store(.)
- in case of adding an element to a full queue make room by forgetting the oldest (front) element so that the new element can be added.void clear()
- quickly purge the queue data by resetting appropriate internal variables.boolean ready()
- return true if at least nShortAv
elements are stored in the queue.T ShortAverage()
- compute the average of the most recent nShortAv
elements.T LongAverage()
- compute the average of all stored elements, note that the queue might not always be full at that time.Need hints?
mySize
until it reaches nLongAv
, increase myBack
by one and roll over to zero at nLongAv
.mySize
and myBack
to their initial values.nShortAv
elements.myBack - nShortAv
and myBack
excluding the one at myBack
.
Beware negative index for the starting point - it's a rollover back to the end of myArray
.myArray
from 0
to mySize
.Test your RotarryBuffer class to verify if the additional functionality that you implemented works correctly. Doing correct testing of your queue by feeding enough data so that all features are tested will also be evaluated. For example add several values, remove several values, add several values again, remove again, make sure that rolling over the end of array works correctly for both ends of the queue after you already added and removed a few items. So testing is not as simple as running the program and entering several random values. For your convenience, the program records data that you entered and the computed results and saves it to a log file entitled "cbuffer_test_log.txt". Only one, the most recent program execution is remembered.
Use the following start up queue library and the provided implementation program. Do not modify the implementation program.
Why the program beeps if short average is greater than four? - promotional link
Submission - ZIP the entire project folder together including the most recent log file that contains the record of your testing. The thoroughness of your testing will be evaluated.