Если это действительно то, что вы делаете в своем коде lot , то вы можете ввести расширение концепции signum
с помощью enum
.
/**
* Extends the signum function to multiple arguments
* <p>
* If all signums are the same then that will be returned.
* <p>
* If any are different - return Mixed.
*/
enum Sign {
Negative, Positive, Zero, Mixed;
public static Sign get(int n) {
return n < 0 ? Negative : n == 0 ? Zero : Positive;
}
public static Sign get(int... n) {
Sign first = get(n[0]);
for(int i = 1; i < n.length; i++) {
if(get(n[i]) != first) {
return Mixed;
}
}
return first;
}
}
Используйте его как:
Sign.get(arg1, arg2, arg3) == Sign.Positive
Вы должны открыть «mytimer» как глобальную переменную. И следует написать: -
if (count == 3 && myAnswer != number)
{
System.out.println("You've reached the maximum trys. Goodbye!");
mytimer.cancel();
}
Работал на меня !!
Надежда поможет.