-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created ComparisonWithDefferentAges.java; Modified CandidateValidator…
….java and StreamPractice.java after mentor's checking
- Loading branch information
1 parent
1e71974
commit 046d440
Showing
3 changed files
with
51 additions
and
30 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package practice; | ||
|
||
import java.util.function.Predicate; | ||
import model.Person; | ||
|
||
public class ComparisonWithDifferentAges implements Predicate<Person> { | ||
private int fromAge; | ||
private int maleToAge; | ||
private int femaleToAge; | ||
|
||
public ComparisonWithDifferentAges(int fromAge, int maleToAge, int femaleToAge) { | ||
this.fromAge = fromAge; | ||
this.maleToAge = maleToAge; | ||
this.femaleToAge = femaleToAge; | ||
} | ||
|
||
@Override | ||
public boolean test(Person person) { | ||
if (person.getSex() == Person.Sex.MAN) { | ||
return person.getAge() >= fromAge | ||
&& person.getAge() <= maleToAge; | ||
} else { | ||
return person.getAge() >= fromAge | ||
&& person.getAge() <= femaleToAge; | ||
} | ||
} | ||
} |
This file contains 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