#include <iostream>
class AudioBuffer {
private:
// TODO: This member is exposed and unsafe. Encapsulate it.
// TODO: Ensure it wraps around 8 (Size = 8).
int head_index;
static const int BUFFER_SIZE = 8;
public:
AudioBuffer() : head_index(0) {}
void advanceHead(int steps)
{
head_index = (head_index + steps) % BUFFER_SIZE;
}
int getHeadIndex() const
{
return head_index;
}
// TODO: Add a method to advance the index safely.
// TODO: Add a getter for printing.
};
int main() {
int N;
if (!(std::cin >> N)) return 0;
AudioBuffer buffer;
for (int i = 0; i < N; ++i) {
int steps;
std::cin >> steps;
// TODO: Replace unsafe direct addition
// buffer.head_index += steps; // This bugs out if index >= 8
buffer.advanceHead(steps);
// Output current state (this might be wrong if not fixed)
std::cout << "Head: " << buffer.getHeadIndex() << std::endl;
}
return 0;
}