-
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.
- Loading branch information
1 parent
c115d4e
commit f0c6eb4
Showing
2 changed files
with
61 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,23 @@ | ||
package practice; | ||
|
||
public class CandidateValidator { | ||
//write your code here | ||
import java.util.function.Predicate; | ||
import model.Candidate; | ||
|
||
public class CandidateValidator implements Predicate<Candidate> { | ||
private static final int PERIOD_TO_NUMBER = 1; | ||
private static final int PERIOD_FROM_NUMBER = 0; | ||
private static final int PERIOD_IN_UKRAINE = 10; | ||
private static final int VALID_NUMBER = 35; | ||
private static final String SPLITTER = "-"; | ||
|
||
@Override | ||
public boolean test(Candidate candidate) { | ||
return candidate.getAge() >= VALID_NUMBER | ||
&& candidate.isAllowedToVote() | ||
&& "Ukrainian".equals(candidate.getNationality()) | ||
&& Integer.parseInt(candidate.getPeriodsInUkr().split(SPLITTER)[PERIOD_TO_NUMBER]) | ||
- Integer.parseInt(candidate.getPeriodsInUkr().split(SPLITTER)[PERIOD_FROM_NUMBER]) | ||
>= PERIOD_IN_UKRAINE; | ||
} | ||
|
||
} |
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