Сравниваю каждый параметр по отдельности через два счетчика. После сравниваю итоговый результат .
Пробовал через 1 счетчик. Пробовал через boolean - все равно не проходит валидацию с требованием сравнить параметеры отдельно.
package com.javarush.task.task05.task0502;
/*
Реализовать метод fight
*/
public class Cat {
public int age;
public int weight;
public int strength;
public Cat() {
}
public boolean fight(Cat anotherCat) {
int th=0;
int an=0;
if (this.age > anotherCat.age) {
th++;
}
else {
if (this.age == anotherCat.age) {
th++;
an++;
}
else an++;
}
if (this.weight > anotherCat.weight) {
th++;
}
else {
if (this.weight == anotherCat.weight) {
th++;
an++;
}
else an++;
}
if (this.strength > anotherCat.strength) {
th++;
}
else {
if (this.strength == anotherCat.strength) {
th++;
an++;
}
else an++;
}
return an > th;
}
public static void main(String[] args) {
}
}