Logical Expressions go brrrrrrrr
This commit is contained in:
parent
33d8ebc901
commit
bbc15604a4
@ -11,19 +11,35 @@ import java.util.concurrent.TimeUnit;
|
|||||||
* @author caleb
|
* @author caleb
|
||||||
*/
|
*/
|
||||||
public class LogicalExpression {
|
public class LogicalExpression {
|
||||||
public static void main(String[] args)
|
|
||||||
{
|
public static void main(String[] args) {
|
||||||
int x = -10;
|
int x = -10;
|
||||||
|
boolean hasCycled = false;
|
||||||
while (true) {
|
while (true) {
|
||||||
System.out.print(((x > 1) || ( x < 100) ) && (x < 0));
|
//System.out.print(((x > 1) || ( x < 100) ) && (x < 0)); //incorrect
|
||||||
System.out.println(": " + x);
|
System.out.print("Logical Expression result: ");
|
||||||
try {
|
System.out.print(x < 100 && x > 1 || (x < 0)); //correct
|
||||||
TimeUnit.MILLISECONDS.sleep(500);
|
System.out.print(": " + x);
|
||||||
}
|
|
||||||
catch(Exception e) {
|
if (x >= 150 && hasCycled == false) {
|
||||||
System.out.println("lol");
|
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++;
|
x++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
TimeUnit.MILLISECONDS.sleep(250); //waits for a specified amount of time
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.print("lol");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user