Все работает, как в условие.
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 sum1=0, sum2=0;
if (this.age > anotherCat.age) sum1+=1;
else sum2+=1;
if (this.weight > anotherCat.weight) sum1+=1;
else sum2+=1;
if (this.strength > anotherCat.strength) sum1+=1;
else sum2+=1;
if (sum1 > sum2)return true;
else return false;
}
public static void main(String[] args) {
Cat cat1 =new Cat();
Cat cat2 = new Cat();
cat1.strength = 9;
cat1.weight = 10;
cat1.age = 5;
cat2.strength = 9;
cat2.weight = 10;
cat2.age = 5;
System.out.println(cat2.fight(cat1));
}
}