Answer the question
In order to leave comments, you need to log in
How to fulfill all conditions without repeating?
I have 4 conditions that must be met together.
if ( условие 1 ) { оператор 1 } ;
if ( условие 2 ) { оператор 2 } ;
if ( ( условие 1 ) && ( условие 2 ) ) { оператор 1; оператор 2; } ;
if ( ( условие 2 ) && ( условие 1 ) ) { оператор 2; оператор 1; } ;
Answer the question
In order to leave comments, you need to log in
Your answer is
if ( condition 1 ) { statement 1 } ;
if ( condition 2 ) { statement 2 } ;
All.
if ( ( условие 1 ) && ( условие 2 ) ) { оператор 1; оператор 2; } ;
if ( ( условие 2 ) && ( условие 1 ) ) { оператор 2; оператор 1; } ;
In my opinion it should be done like this:
if ( условие 1 && !(( условие 1 ) && ( условие 2 )) ) { оператор 1 } ;
if ( условие 2 && !(( условие 1 ) && ( условие 2 )) ) { оператор 2 } ;
if ( ( условие 1 ) && ( условие 2 ) ) { оператор 1; оператор 2; } ;
if ( ( условие 2 ) && ( условие 1 ) ) { оператор 2; оператор 1; } ;
In general, I made this method of checking and hung it on the buttons. Now it works as it should without additional conditions.
Button playOne, playTwo;
...
playOne = (Button) findViewById(R.id.playOne);
playTwo = (Button) findViewById(R.id.playTwo);
...
public void verification(Button b) {
if (b == playOne) { playSound(sound_one); }
if (b == playTwo) { playSound(sound_two); }
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question