大神们看一下怎么优化这个代码
package example;
import java.util.*;
public class Example {
public void computeScore(String type, Double score, Double sum) {
HashMap<String, Double> map = new HashMap<String, Double>(){ {
map.put("type1", 0.1);
map.put("type1", 0.2);
map.put("type1", 0.3);
map.put("type1", 0.4);
map.put("type1", 0.5);
map.put("type1", 0.6);
map.put("type1", 0.7); } };
if (map.containsKey(type)) {
sum += score * map.get(type);
}
}
}