мало того что не нравиться валидатору, еще и подсвечивает "static class Cat",,
package com.javarush.task.task05.task0505;
/*
Кошачья бойня
*/
public class Solution {
public static void main(String[] args) {
Cat cat1=new Cat("вася",6,7,8);
Cat cat2=new Cat("коля",4,8,9);
Cat cat3=new Cat("эмма",1,3,8);
if(cat1.fight(cat2)){
System.out.println(cat1.name + "выиграл" + cat2.name);
}
if(cat2.fight(cat3)){
System.out.println(cat2.name + " выиграл " + cat3.name);
}
if(cat3.fight(cat1)){
System.out.println(cat3.name + " выиграл " + cat1.name);
}
}
}
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;
}
}
}