我需要做的是,计算两个客户评分之间的点积距离。客户的评分记录在哈希图中。
private HashMap<String,int[]> ratingmap;
哈希图中的键是客户名称,与之相关的是该客户的评分(他对书籍的评分)
我将如何做到这一点?
/**
* calculate dot product distance between the ratings of two customers
* @param name1 String name of customer
* @param name2 String name of customer
* @return int distance or ILLEGAL_INPUT if name1 or name2 are not customers
*/
public int distance(String name1, String name2)
{
return 0; //replace with code
}
RatingsAnalysis
这是课堂上给出的其他细节
//collection of rated book titles
private BookList books;
//collection of customers and their ratings
private RatingsMap ratings;
//use a list of customer names from the ratings map for looping through the map
private ArrayList<String> customernames;