Assignment 8

Due: Thursday, November 17, 2005


Grading(Maximum Score 100):

Points will be taken off for not meeting all requirements. 5 points will be taken off for each class or method that does not have documentation! Documentation is defined as a written description of what the method or class does. This can be as short as a couple words or as long as a paragraph. Documentation MUST be in JavaDoc Format!

Overview:

In this assignment you will develop a Generic class, and continue to practice with thread safety.

Detail:

For this assignment you will develop 2 classes. One will implement a circular buffer and the other will provide a testing program for the first class.

Circular Buffer

The circular buffer for this assignment will be defined as a fixed size, through the use of a constructor parameter. It will allow the adding of any object type to be added to the Buffer. It MUST be implemented as a generic class. It will provide only two public methods, no public variables, and one constructor. The circular buffer may be implemented using any data structure you would like(Arrays, linked lists...) Access to this class must be THREAD SAFE!

Constructor

The constructor will take as a parameter the size of the Circular buffer. Other parameters may be passed if found useful.

Two public methods

The first method will provide a means to add an object into the buffer. When the maximum number of objects has been added, each additional object must replace the current oldest object in the buffer. For Example: Assuming the size of the buffer is 10, the buffer will always contain the last 10 objects that have been added.

The second method will be a "toArray" method that will return a new array of references to the current objects in the circular buffer. The array should be ordered from last added to first added.

Test class

This class will create a new instance of the circular buffer class with a size of 5. It will then add 7 unique strings to the circular buffer. The contents of the circular buffer should then be printed using a for loop, to verify that both of the public methods perform correctly.

Hand In:

A print out of your code. Print out of the run.