For an arbitrary set of objects, conforming to the Distant interface, find all of the objects organized
Question:
For an arbitrary set of objects, conforming to the Distant interface, find all of the objects organized by distance to a specified target object.
Complete the constructor, findNearest, add & clear methods of the Nearest class. You may add any additional code you believe necessary to this class. The tester code and other supporting classes have been provided for reference.
You cannot make use of a binary search tree, any classes that implement the Java Map interface, or any code or classes designed to sort.
public class Nearest {
/**
* Constructor to find the nearest values to a specified target
*/
public Nearest() {
//Code here
}
/**
* Return an array of objects nearest to the target object
* @param target
* @return resulting array of objects in nearest order
*/
public T[] findNearest(T target) {
//Code here
}
/**
* Add an individual value to the set of values to be evaluated.
* @param value
*/
public void add(T value) {
//Code here
}
/**
* Clear the pool of values stored.
*/
public void clear() {
//Code here
}
// Add any additional code or instance variables required here
//Code here
}
Statistics for Management and Economics Abbreviated
ISBN: 978-1285869643
10th Edition
Authors: Gerald Keller