Created
January 30, 2020 00:56
-
-
Save peterdcasey/a0652a6fa8df87890176d8941e7c3b22 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* TesterBool | |
* <br> | |
* <p>Build a logical expression using True(#) and False(#) | |
* method calls. Number the T/F calls sequentially, left to right. | |
* </p> | |
* <p>The output displays the numbers of the called methods, if | |
* evaluated, and the final result. | |
* </p> | |
* <p>Example: False(1) && (True(2) || False(3)) || True(4) | |
* </p> | |
* <p>Output: 1 4 --> true | |
* </p> | |
* | |
* @author Peter | |
* @version 0.03 | |
*/ | |
public class TesterBool | |
{ | |
/** | |
* Main method, add boolean expression here. | |
*/ | |
public static void main(String[] args) { | |
boolean expr = true; | |
//expr = False(1) && (True(2) || False(3)) || True(4) ; | |
//expr = (True(1) && False(2)) || True(3) ; | |
expr = False(1) || True(2) && False(3) ; | |
//expr = !(False(1) && (True(2)) || False(3)) || True(4) ; | |
System.out.println(" --> " + expr); | |
} | |
/** | |
* Pass true and expression number to display | |
*/ | |
private static boolean True(int num) { | |
return showExprNum(true, num); | |
} | |
/** | |
* Pass false and expression number to display | |
*/ | |
private static boolean False(int num) { | |
return showExprNum(false, num); | |
} | |
/** | |
* Print expression number and return boolean | |
*/ | |
private static boolean showExprNum(boolean expr, int exprNum) { | |
System.out.print(" " + exprNum + " "); | |
return expr; | |
} | |
private TesterBool() {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment