Уж и не знаю, как быть. Вроде все учтено. Когда коты равноценны, сравниваю их хеш-коды. Даже и не знаю, как по-другому. Подскажите, где ошибка, пожалуйста.
package com.javarush.task.task05.task0502;
/*
Реализовать метод fight
*/
public class Cat {
public int age;
public int weight;
public int strength;
public Cat() {
}
public boolean fight(Cat anotherCat) {
int k1=0;
int k2=0;
if (this.weight>weight){
k1++;
}else{
if (this.weight<weight){
k2++;
}
}
if (this.age>age){
k1++;
}else{
if (this.age<age){
k2++;
}
}
if (this.strength>strength){
k1++;
}else{
if (this.strength<strength){
k2++;
}
}
if (k1!=k2){
return (k1>k2);
}else{
int a=this.hashCode();
int b=anotherCat.hashCode();
return (a>b);
}
}
public static void main(String[] args) {
}
}