Вроде все просто и понятно, это уже не первый способ решения. Добавил всевозможные тесты (3!) + ничья. Все проходит отлично. Спасибо
package en.javarush.task.jdk13.task05.task0501;
/*
Cat carnage (1)
*/
import java.util.Arrays;
public class Solution {
public static void main(String[] args) {
Cat kara = new Cat("Kara", 3, 4, 78);
Cat dobby = new Cat("Dobby", 1, 2, 64);
Cat zlo = new Cat("Zlo", 12, 7, 99);
Cat tieTest1 = new Cat("Test1", 10, 10, 10);
Cat tieTest2 = new Cat("Test2", 10, 10, 10);
// System.out.println(kara.fight(dobby));
// System.out.println(dobby.fight(kara));
// System.out.println(zlo.fight(kara));
// System.out.println(dobby.fight(zlo));
// System.out.println(zlo.fight(dobby));
// System.out.println("\n");
// System.out.println(tieTest1.fight(tieTest2));
}
public static class Cat {
private String name;
private int age;
private int weight;
private int strength;
public Cat(String name, int age, int weight, int strength) {
this.name = name;
this.age = age;
this.weight = weight;
this.strength = strength;
}
public boolean fight(Cat cat) {
int [] ar1 = {this.age,this.weight,this.strength};
int [] ar2 = {cat.age,cat.weight,cat.strength};
boolean result = (Arrays.compare(ar1,ar2)) >0;
return result;
}
}
}