No se que está mal. Da el resultado correcto.
package en.codegym.task.jdk13.task05.task0501;
/*
Cat carnage (1)
*/
public class Solution {
public static void main(String[] args)
{
Cat cat1 = new Cat("Name1", 5, 10, 5);
Cat cat2 = new Cat("Name2", 6, 10, 5);
Cat cat3 = new Cat("Name3", 6, 11, 6);
System.out.println(cat1.fight(cat2));
System.out.println(cat2.fight(cat1));
System.out.println(cat1.fight(cat3));
System.out.println(cat3.fight(cat1));
System.out.println(cat2.fight(cat3));
System.out.println(cat3.fight(cat2));
}
public static class Cat {
//write your code here
public boolean fight(Cat cat)
{
boolean resultado = false;
resultado = (this.strength > cat.strength) ? true : false;
if(this.strength == cat.strength)
{
resultado = (this.weight > cat.weight) ? true : false;
if (this.weight == cat.weight)
{
resultado = (this.age > cat.age) ? true : false;
if (this.age == cat.age)
{
resultado = false;
}
}
}
return resultado;
}
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;
}
}
}