я полагаю что загвоздка в этом условии
должно выполняться условие:
если cat1.fight(cat2) возвращает true,
то cat2.fight(cat1) должен возвращать false.
вообще не могу понять что делать если cat1 победил то тру если нет то фолс , а ниже в условии потом написано что если ничья то вернуть либо фолс либо тру, но если мы вернем тру это будет означать что cat1 победил anotherCat. Или я уже совсем запутался...
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 c1, c2;
c1 = 1;
c2 = 1;
if (this.age > anotherCat.age) c1++;
if (this.age < anotherCat.age) c2++;
if (this.age == anotherCat.age) c1++; c2++;
if (this.weight > anotherCat.weight) c1++;
if (this.weight < anotherCat.weight) c2++;
if (this.weight == anotherCat.weight) c1++; c2++;
if (this.strength > anotherCat.strength) c1++;
if (this.strength < anotherCat.strength) c2++;
if (this.strength == anotherCat.strength) c1++; c2++;
if (c1 > c2)
return true;
if (c1 < c2)
return false;
if (c1 == c2)
return true;
else
return false;
}
public static void main(String[] args) {
}
}