В консоли интележи вывод false, если коты ровны(в комментариях написаны результаты из консоли), но проверку почему то не проходит. Почему?
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 cat1Count = 0;
int cat2Count = 0;
if (this.age > anotherCat.age) {
cat1Count++;
} else if (anotherCat.age > this.weight) {
cat2Count++;
}
if (this.weight > anotherCat.weight) {
cat1Count++;
} else if (anotherCat.weight > this.weight) {
cat2Count++;
}
if (this.strength > anotherCat.strength) {
cat1Count++;
} else if (anotherCat.strength > this.strength) {
cat2Count++;
}
if (cat1Count > cat2Count) {
return true;
} else {
return false;
}
}
public static void main(String[] args) {
Cat cat1 = new Cat();
cat1.strength = 1;
cat1.weight = 1;
cat1.age = 1;
Cat cat2 = new Cat();
cat2.age = 1;
cat2.weight = 1;
cat2.strength = 1;
Cat cat3 = new Cat();
cat3.age = 3;
cat3.weight = 5;
cat3.strength = 4;
System.out.println(cat1.fight(cat2)); //false cat1 == cat2
System.out.println(cat2.fight(cat1)); //false cat2 == cat1
System.out.println(cat1.fight(cat3)); //false cat1 < cat3
System.out.println(cat3.fight(cat1)); //true cat3 > cat1
}
}