Instructions

The purpose of this mini-project is to give you practice with implementing an API.

Create a module called MP5. In MP5, create the classes necessary to implement and test the following API. Remember that APIs are public facing, so your only public methods should be those described below, though you can use whatever private methods and data members you would like.

This API is for a simple statistics library called SimpleStats. It should have the following methods:

MethodDescription
SimpleStats() The default constructor
SimpleStats(data:float[]) A constructor that takes in the data to process as an array. Throws an InsufficientData exception if data is empty.
SimpleStats(data:Iterable<float>) A constructor that takes in the data to process as any kind of Iterable data structure (e.g., an ArrayList). Throws an InsufficientData exception if data is null or empty.
setData(data:float[]):void Sets the data to be processed. Throws an InsufficientData exception if data is empty.
setData(data:Iterable<float>):void Sets the data to be processed. Throws an InsufficientData exception if data is null or empty.
getData():ArrayList<float> Returns the data as an ArrayList. Throws an InsufficientData exception if data is null or empty.
mean():float Returns the mean of the data. Throws an InsufficientData exception if no data is present.
median():float Returns the median value in the data. Throws an InsufficientData exception if no data is present.
max():float Returns the max value in the data. Throws an InsufficientData exception if no data is present.
min():float Returns the minimum value in the data. Throws an InsufficientData exception if no data is present.

You should include unit tests for each method.

Submission

Create a JAR file for MP5. See this page for the rubric. See the Canvas page to upload your submission.

(Back to top)