Что ж ему не нравится, логика вроде правильная, а ему не нравится? Не хочется смотреть готовый ответ и использовать его, так как там сделано через Integer.compare а я с ним не знаком
package com.javarush.task.jdk13.task05.task0501;
public class Solution {
public static class Cat {
private String name;
private int age;
private int weight;
private int strength;
public Cat(String name, int age, int weight, int strength){
this.name = name;
this.age = age;
this.weight = weight;
this.strength = strength;
}
public boolean fight(Cat anotherCat)
{
int thisCat = 0;
int enemyCat =0;
if (age > anotherCat.age){
thisCat++;
}
else if(age <= anotherCat.age){
enemyCat++;
}
if (weight > anotherCat.weight){
thisCat++;
}
else if (weight <= anotherCat.weight){
enemyCat++;
}
if (strength > anotherCat.strength){
thisCat++;
}
else if (strength <= anotherCat.strength){
enemyCat++;
}
return enemyCat >= thisCat?false:true;
}
}
public static void main(String[] args) {
Cat cat1 = new Cat("Murzik",5,6,20);
Cat cat2 = new Cat("Barsik",6,7,18);
Cat cat3 = new Cat("Sanya",8,5,19);
}
}