Created
December 10, 2011 18:07
-
-
Save paddya/1455794 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Person findMostSimilarTo(Person p) { | |
Person bestMatch = null; | |
Profile ownProfile = this.getProfile(p); | |
int bestScore = 0; | |
for(int i = 0; i < this.profiles.length; i++) { | |
// don't compare the person with itself | |
if(p.equals(this.profiles[i].getOwner())) { | |
continue; | |
} | |
int currentScore = ownProfile.countSimilarities(this.profiles[i]); | |
if(currentScore > bestScore || bestMatch == null) { | |
bestScore = currentScore; | |
bestMatch = this.profiles[i].getOwner(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment