Created
November 26, 2019 07:59
-
-
Save hongbeomi/c9d35aa7e49c9c8b880ee8e586a0fcea to your computer and use it in GitHub Desktop.
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
// 선택 조건을 결정하는 인터페이스 정의 | |
public interface ApplePredicate{ | |
boolean test (Apple apple); | |
} | |
// 무거운 사과만 선택 | |
public class AppleHeavyWeightPredicate implements ApplePredicate { | |
public boolean test(Apple apple) { | |
return apple.getWeight() > 150; | |
} | |
} | |
// 녹색 사과만 선택 | |
public class AppleGreenColorPredicate implements ApplePredicate { | |
public boolean test(Apple apple) { | |
return GREEN.equals(apple.getColor()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment