The Profile Class and the SRP

Let’s take a look at our Profile class so far:

iloveyouboss/23/src/iloveyouboss/Profile.java
 
public​ ​class​ Profile {
 
private​ ​Map​<​String​,Answer> answers = ​new​ ​HashMap​<>();
 
 
private​ ​int​ score;
 
private​ ​String​ name;
 
 
public​ Profile(​String​ name) {
 
this.name = name;
 
}
 
 
public​ ​String​ getName() {
 
return​ name;
 
}
 
 
public​ ​void​ add(Answer answer) {
 
answers.put(answer.getQuestionText(), answer);
 
}
 
 
public​ ​boolean​ matches(Criteria criteria) {
 
calculateScore(criteria);
 
if​ (doesNotMeetAnyMustMatchCriterion(criteria))
 
return​ false;
 
return​ anyMatches(criteria);
 
}
 
 
private​ ​boolean​ doesNotMeetAnyMustMatchCriterion(Criteria criteria) {
 

Get Pragmatic Unit Testing in Java 8 with JUnit now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.