diff --git a/mavenproject1/src/main/java/com/mycompany/mavenproject1/LogicalExpression.java b/mavenproject1/src/main/java/com/mycompany/mavenproject1/LogicalExpression.java index f03c56f..02c8ab9 100644 --- a/mavenproject1/src/main/java/com/mycompany/mavenproject1/LogicalExpression.java +++ b/mavenproject1/src/main/java/com/mycompany/mavenproject1/LogicalExpression.java @@ -11,19 +11,35 @@ import java.util.concurrent.TimeUnit; * @author caleb */ public class LogicalExpression { - public static void main(String[] args) - { + + public static void main(String[] args) { int x = -10; + boolean hasCycled = false; while (true) { - System.out.print(((x > 1) || ( x < 100) ) && (x < 0)); - System.out.println(": " + x); + //System.out.print(((x > 1) || ( x < 100) ) && (x < 0)); //incorrect + System.out.print("Logical Expression result: "); + System.out.print(x < 100 && x > 1 || (x < 0)); //correct + System.out.print(": " + x); + + if (x >= 150 && hasCycled == false) { + hasCycled = true; + } else if (x <= -10) { + hasCycled = false; + } + + if (hasCycled) { + System.out.println(" state: currently subtracting 1"); + x--; + } else { + System.out.println(" state: currently adding 1"); + x++; + } + try { - TimeUnit.MILLISECONDS.sleep(500); + TimeUnit.MILLISECONDS.sleep(250); //waits for a specified amount of time + } catch (Exception e) { + System.out.print("lol"); } - catch(Exception e) { - System.out.println("lol"); - } - x++; } } } diff --git a/mavenproject1/target/classes/com/mycompany/mavenproject1/LogicalExpression.class b/mavenproject1/target/classes/com/mycompany/mavenproject1/LogicalExpression.class index 3bc2e2f..f5547ce 100644 Binary files a/mavenproject1/target/classes/com/mycompany/mavenproject1/LogicalExpression.class and b/mavenproject1/target/classes/com/mycompany/mavenproject1/LogicalExpression.class differ