Программа должна вывести результат каждого боя с новой строки.
package com.javarush.task.task05.task0505;
/*
Кошачья бойня
*/
public class Solution {
public static void main(String[] args) {
Cat a = new Cat("a",3,30,8);
Cat b = new Cat("b",2,20,5);
Cat c = new Cat("c",5,40,9);
a.fight(b);
b.fight(c);
c.fight(a);
System.out.println(fight.score);
}//напишите тут ваш код
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 ageScore = Integer.compare(this.age, anotherCat.age);
int weightScore = Integer.compare(this.weight, anotherCat.weight);
int strengthScore = Integer.compare(this.strength, anotherCat.strength);
int score = ageScore + weightScore + strengthScore;
return score > 0; // return score > 0 ? true : false;
}
}
}