подставляла разные значения. Я чего то не догоняю. обьясните пожалуйста условие.
ри разных значениях результат тот что требунется. 😭
return age > anotherCat.age && strength > anotherCat.strength && weight > anotherCat.weight
||age <= anotherCat.age && strength > anotherCat.strength && weight > anotherCat.weight
||age > anotherCat.age && strength <= anotherCat.strength && weight > anotherCat.weight
||age > anotherCat.age && strength > anotherCat.strength && weight <= anotherCat.weight;
уже переделала.все равно 4 условие не проходит.
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) {
return age > anotherCat.age
||strength > anotherCat.strength
||weight > anotherCat.weight
||age > anotherCat.age && strength > anotherCat.strength
||age > anotherCat.age && weight > anotherCat.weight
|| weight > anotherCat.weight && strength > anotherCat.strength
|| weight > anotherCat.weight && strength > anotherCat.strength && weight > anotherCat.weight;
}
public static void main(String[] args) {
Cat cat1 = new Cat();
cat1.age = 1;
cat1.weight = 3;
cat1.strength = 8;
Cat cat2 = new Cat();
cat2.age = 2;
cat2.weight = 4;
cat2.strength = 9;
System.out.println(cat2.fight(cat1));
System.out.println(cat1.fight(cat2));
}
}