Приветствую, правильно ли я понимаю что 4е условие не выполняется из-за конструкции: if ((ageScore > 0) && (weightScore > 0 || strengthScore > 0)) ? И можно ли как-то компактнее сделать И/ИЛИ ?
package com.javarush.task.task05.task0502;
/*
Реализовать метод fight
*/
import java.util.Comparator;
public class Cat {
public int age;
public int weight;
public int strength;
public Cat() {
}
public boolean fight(Cat anotherCat) {
/*int ageScore = Integer.compare(this.age, anotherCat.age);
int weightScore = Integer.compare(this.weight, anotherCat.weight);
int strengthScore = Integer.compare(this.strength, anotherCat.strength);
if (((ageScore > 0) && (weightScore > 0 || strengthScore > 0)) || (ageScore > 0 & weightScore > 0 & strengthScore > 0)){
return true;
}
else {
return false;
}*/
int count = 0;
/*count += Integer.compare(this.age, anotherCat.age);
count += Integer.compare(this.weight, anotherCat.weight);
count += Integer.compare(this.strength, anotherCat.strength);*/
if (this.age > anotherCat.age) count++;
else if (anotherCat.age > this.age) count--;
if (this.weight > anotherCat.weight) count++;
else if (anotherCat.weight > this.weight) count--;
if (this.strength > anotherCat.strength) count++;
else if (anotherCat.strength > this.strength) count--;
if (count >= 2) return true;
else return false;
//напишите тут ваш код
}
public static void main(String[] args) {
}
}