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
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
}
Step by Step Solution
3.29 Rating (146 Votes )
There are 3 Steps involved in it
To solve this problem we must implement a class Nearest that supports managing a set of objects conforming to the Distant interface which have measura... View full answer
Get step-by-step solutions from verified subject matter experts
