Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package de.uniwue.gdp.pdd.rules;
- import de.uniwue.gdp.pdd.deck.Card;
- import java.util.function.BiPredicate;
- public class Rules {
- public static BiPredicate<Card, Card> sameValueRule(){
- return new BiPredicate<Card, Card>() {
- @Override
- public boolean test(Card t, Card u) {
- if (t.value() == u.value()){
- return true;
- } else {
- return false;
- }
- // Oder in einer Zeile:
- // return t.value() == u.value();
- }
- };
- }
- public static BiPredicate<Card, Card> sameSuitRule(){
- return new BiPredicate<Card, Card>() {
- @Override
- public boolean test(Card t, Card u) {
- if (t.suit() == u.suit()){
- return true;
- } else {
- return false;
- }
- }
- };
- }
- public static BiPredicate<Card, Card> increasingValueRule(){
- return new BiPredicate<Card, Card>() {
- @Override
- public boolean test(Card t, Card u) {
- if (t.value() < u.value()){
- return true;
- } else {
- return false;
- }
- }
- };
- }
- public static BiPredicate<Card, Card> jokerRule(Card joker){
- return new BiPredicate<Card, Card>() {
- @Override
- public boolean test(Card t, Card u) {
- if (u.equals(joker)){
- return true;
- } else {
- return false;
- }
- }
- };
- }
- public static BiPredicate<Card, Card> jokerRuleByValue(int value){
- return new BiPredicate<Card, Card>() {
- @Override
- public boolean test(Card t, Card u) {
- if (u.value() == value){
- return true;
- } else {
- return false;
- }
- }
- };
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement