@Test(expected = IllegalStateException.class) public void testOverflow() { Buffer charQueue = new Buffer(3); charQueue.enqueue('a'); charQueue.enqueue('b'); charQueue.enqueue('c'); charQueue.enqueue('d'); }
public void enqueue(char character) { if (isFull()) { throw new IllegalStateException( "Not enough capacity to enqueue element"); } else { buffer[(head + length()) % getCapacity()] = character; ++size; } }
Buffer implements CharSequence { public void enqueue(char character) { if (isFull()) { throw new IllegalStateException( "Not enough capacity to enqueue element"); } else { buffer[(head + length()) % getCapacity()] = character; ++size; } } }
Buffer implements CharSequence { public void enqueue(char character) { if (isFull()) { throw new IllegalStateException( "Not enough capacity to enqueue element"); } else { buffer[(head + length()) % getCapacity()] = character; ++size; } } private  Buffer(char[] buffer, int head, int size);  Buffer(int capacity); }
Buffer implements CharSequence { public void enqueue(char character) { if (isFull()) { throw new IllegalStateException( "Not enough capacity to enqueue element"); } else { buffer[(head + length()) % getCapacity()] = character; ++size; } } private  Buffer(char[] buffer, int head, int size);  Buffer(int capacity); int getCapacity(); void enqueue(char character); void dequeue(); void forceEnqueue(char character); int length(); char charAt(int index); CharSequence subSequence(int start, int end); String toString(); }
Buffer implements CharSequence { public void enqueue(char character) { if (isFull()) { throw new IllegalStateException( "Not enough capacity to enqueue element"); } else { buffer[(head + length()) % getCapacity()] = character; ++size; } } private  Buffer(char[] buffer, int head, int size);  Buffer(int capacity); int getCapacity(); void enqueue(char character); void dequeue(); void forceEnqueue(char character); int length(); char charAt(int index); CharSequence subSequence(int start, int end); String toString();  }