From 5d3ae971fd182de64fb377af6c62a6dd51587d39 Mon Sep 17 00:00:00 2001
From: tkhambir
Date: Mon, 27 Jul 2020 18:37:04 +0300
Subject: [PATCH 1/2] homework 1.2 solution
---
src/main/java/core/basesyntax/BooleanExpression.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/main/java/core/basesyntax/BooleanExpression.java b/src/main/java/core/basesyntax/BooleanExpression.java
index f8cfc8e..2ae62aa 100644
--- a/src/main/java/core/basesyntax/BooleanExpression.java
+++ b/src/main/java/core/basesyntax/BooleanExpression.java
@@ -14,6 +14,8 @@ public class BooleanExpression {
* без использования конструкций if-else
*/
public boolean booleanExpression(boolean a, boolean b, boolean c, boolean d) {
- return false;
+ return (a & b & !c & !d) | (a & c & !b & !d)
+ | (a & d & !b & !c) | (b & c & !a & !d)
+ | (b & d & !a & !c) | (c & d & !b & !a);
}
}
From 9652d2228c98c39ebddfb96832490fa3a95d6134 Mon Sep 17 00:00:00 2001
From: tkhambir
Date: Mon, 27 Jul 2020 19:54:58 +0300
Subject: [PATCH 2/2] - XOR operator added - redundant statements excluded
---
src/main/java/core/basesyntax/BooleanExpression.java | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/main/java/core/basesyntax/BooleanExpression.java b/src/main/java/core/basesyntax/BooleanExpression.java
index 2ae62aa..32aa402 100644
--- a/src/main/java/core/basesyntax/BooleanExpression.java
+++ b/src/main/java/core/basesyntax/BooleanExpression.java
@@ -14,8 +14,6 @@ public class BooleanExpression {
* без использования конструкций if-else
*/
public boolean booleanExpression(boolean a, boolean b, boolean c, boolean d) {
- return (a & b & !c & !d) | (a & c & !b & !d)
- | (a & d & !b & !c) | (b & c & !a & !d)
- | (b & d & !a & !c) | (c & d & !b & !a);
+ return (a ^ b) && (c ^ d) || (a ^ c) && (b ^ d);
}
}