Сравнила три параметра, потестировала. По условию вроде все верно. Но на сайте задача не прошла тестирование. Подскажите, пожалуйста, что не так.
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 x = 0;
if (age > anotherCat.age) {
x++;
//System.out.println(x);
}
if (weight > anotherCat.weight) {
x++;
//System.out.println(x);
}
if (strength > anotherCat.strength) {
x++;
//System.out.println(x);
}
if (x >= 2) {
//System.out.println(x);
return true;
} else {
//System.out.println(x);
return false;
}
}
public static void main(String[] args) {
Cat cat1 = new Cat();
cat1.age = 3;
cat1.weight = 3;
cat1.strength = 3;
Cat cat2 = new Cat();
cat2.age = 3;
cat2.weight = 3;
cat2.strength = 3;
System.out.println(cat2.fight(cat1));
// System.out.println();
}
}