Why am I getting an error, that I need to conduct three fights, when I obviously do?
package com.codegym.task.task05.task0505;
/*
Feline carnage
*/
public class Solution {
public static void main(String[] args) {
Cat loki = new Cat("Loki", 2, 10, 666);
Cat behemoth = new Cat("Behemoth", 6, 9, 450);
Cat freya = new Cat("Freya", 1, 6, 333);
loki.fight(behemoth);
System.out.println(loki.fight(behemoth));
// loki.fight(behemoth);
// System.out.println(loki.fight(behemoth));
freya.fight(loki);
System.out.println(freya.fight(loki));
// loki.fight(freya);
// System.out.println(loki.fight(freya));
behemoth.fight(freya);
System.out.println(behemoth.fight(freya));
//write your code here
}
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;
}
}
}