Let a,b,c be a boolean value. I need to print all values of expression a && b && c. I'm writing the class
public class BooleanTriple{
private boolean a,b,c;
public BooleanTriple(boolean a, boolean b, boolean c){ this.a =a; this.b=b; this.c=c;}
/**
*Increments the value of triple with lexicographical ordering
*/
public void incr(){
if (!a) a=true;
else if(!b){
a= false;
b= true;
else if (!c){
a= false;
b= false;
c=true;
}
}
public boolean logProduct(){ return a && b && c;}
}
And Main class:
public class Main{
BooleanTriple bTriple = new BooleanTriple(false,false,false);
public static void main(String[] args){
for (int i=0; i<8; i++){
System.out.println(bTriple.logProduct());
bTriple.incr();
}
}
}
But i think, that it's bad implementation. Can you correct me?
else if
block in theBooleanTriple
class. Also please be more precise in what actually you are trying to do. I honestly don't understand your description and your question. \$\endgroup\$