You need to conduct three fights.
package com.codegym.task.task05.task0505;
/*
Feline carnage
*/
public class Solution {
public static void main(String[] args) {
Cat c = new Cat("c", 9, 10, 66);
Cat cc = new Cat("cc", 6, 9, 45);
Cat ccc = new Cat("ccc", 7, 8, 55);
c.fight(cc);
System.out.println(c.fight(cc));
c.fight(ccc);
System.out.println(c.fight(ccc));
cc.fight(ccc);
System.out.println(cc.fight(ccc));
}
public static class Cat {
protected String name;
protected int age;
protected int weight;
protected 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 anotherCat) {
int ageAdvantage = this.age > anotherCat.age ? 1 : 0;
int weightAdvantage = this.weight > anotherCat.weight ? 1 : 0;
int strengthAdvantage = this.strength > anotherCat.strength ? 1 : 0;
int score = ageAdvantage + weightAdvantage + strengthAdvantage;
return score > 2; // return score > 2 ? true : false;
}
}
}