Считает правильно.
Но пишет что это условие не прошло проверку:
-В методе fight реализовать механизм драки котов в зависимости от их веса, возраста и силы согласно условию.
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 a = this.age > anotherCat.age ? 1 : 0;
int w = this.weight > anotherCat.weight ? 1 : 0;
int s = this.strength > anotherCat.strength ? 1 : 0;
int score = a + w + s;
return score > 2;//напишите тут ваш код
}
public static void main(String[] args) {
Cat cat1 = new Cat();
cat1.age = 10;
cat1.weight = 10;
cat1.strength = 10;
Cat cat2 = new Cat();
cat2.age = 10;
cat2.weight = 1;
cat2.strength = 1;
System.out.println(cat1.fight(cat2));
}
}