下面是我的JAVA方法
public static List<Match<String, String>> Decider
(List<Preference<String, String>> hospitalPrefs,List<Preference<String, String>> studentPrefs)
{
Match<String, String> matching = new Match<String, String>(null, null);
List<Match<String, String>> matcher = new ArrayList<Match<String, String>>();
/** Matching the preference of the hospital with the student */
for(int hospitalLoop = 0;hospitalLoop < hospitalPrefs.size(); hospitalLoop++)
{
String hospitalPreferrer = hospitalPrefs.get(hospitalLoop).getPreferrer();
String hospitalPreferred = hospitalPrefs.get(hospitalLoop).getPreferred();
int hospitalValue = hospitalPrefs.get(hospitalLoop).getValue();
for(int studentLoop = 0;studentLoop < studentPrefs.size();studentLoop++)
{
String studentPreferrer = studentPrefs.get(studentLoop).getPreferrer();
String studentPreferred = studentPrefs.get(studentLoop).getPreferred();
int studentValue = studentPrefs.get(studentLoop).getValue();
if(hospitalPreferred.equals(studentPreferrer)
&& hospitalPreferrer.equals(studentPreferred)
&& hospitalValue == studentValue)
{
System.out.println(hospitalPreferred + "," + studentPreferred);
matching.setItem1(hospitalPreferred);
matching.setItem2(studentPreferred);
matcher.add(matching);
break;
}
}
}
return matcher;
}
matcher 变量覆盖列表。我对此感到困惑。
就像我添加
a,b,c 一样。
在 matcher 变量中添加 c,c,c
我很困惑我哪里出错了。
谢谢 !!!