From 07d98588f58e3b433ed26c5fbfa12baf74c063e5 Mon Sep 17 00:00:00 2001 From: Borisko130 Date: Mon, 27 Jul 2020 18:47:37 +0300 Subject: [PATCH 1/2] Homework 2 completed --- src/main/java/core/basesyntax/BooleanExpression.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/core/basesyntax/BooleanExpression.java b/src/main/java/core/basesyntax/BooleanExpression.java index f8cfc8e..043f434 100644 --- a/src/main/java/core/basesyntax/BooleanExpression.java +++ b/src/main/java/core/basesyntax/BooleanExpression.java @@ -14,6 +14,11 @@ public class BooleanExpression { * без использования конструкций if-else

*/ public boolean booleanExpression(boolean a, boolean b, boolean c, boolean d) { - return false; + return (!a & !b & c & d) + || (!a & b & !c & d) + || (!a & b & c & !d) + || (a & !b & !c & d) + || (a & !b & c & !d) + || (a & b & !c & !d); } } From f1d0331299e7240b03cd835ce81bfc28e25f4140 Mon Sep 17 00:00:00 2001 From: Borisko130 Date: Tue, 28 Jul 2020 09:51:00 +0300 Subject: [PATCH 2/2] Simplified boolean expression --- src/main/java/core/basesyntax/BooleanExpression.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/main/java/core/basesyntax/BooleanExpression.java b/src/main/java/core/basesyntax/BooleanExpression.java index 043f434..1ca7018 100644 --- a/src/main/java/core/basesyntax/BooleanExpression.java +++ b/src/main/java/core/basesyntax/BooleanExpression.java @@ -14,11 +14,6 @@ public class BooleanExpression { * без использования конструкций if-else

*/ public boolean booleanExpression(boolean a, boolean b, boolean c, boolean d) { - return (!a & !b & c & d) - || (!a & b & !c & d) - || (!a & b & c & !d) - || (a & !b & !c & d) - || (a & !b & c & !d) - || (a & b & !c & !d); + return (a ^ c && b ^ d) || (a ^ d && b ^ c); } }