Если в 26 строке указать win>1 то выдаёт ошибку : Проверь, что метод fight работает правильно, если у котов два параметра равны, и только один отличается.
Если той же строке указать win>0 то выдаёт ошибку : Убедись, что кот выигрывает бой, если он превосходит противника по двум или трем параметрам.
Какие-то два противоречащие друг другу условия.
Я так понял, что, если превосходит только по одному параметру, то это ничья. Это так?
Помогите, пожалуйста, разобраться.
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 win = 0;
if (this.age > anotherCat.age)
win++;
if (this.weight > anotherCat.weight)
win++;
if (this.strength > anotherCat.strength)
win++;
if (win>0)
return true;
else
return false;
}
public static void main(String[] args) {
Cat a = new Cat();
Cat b = new Cat();
a.age=2;
b.age=1;
a.weight=1;
b.weight=1;
a.weight=1;
b.weight=1;
System.out.println(a.fight(b));
}
}
/*
if (this.age > anotherCat.age&&(this.weight > anotherCat.weight||this.strength > anotherCat.strength))
return true;
else if (this.weight > anotherCat.weight&&(this.age > anotherCat.age||this.strength > anotherCat.strength))
return true;
else if (this.strength > anotherCat.strength&&(this.age > anotherCat.age||this.strength > anotherCat.strength))
return true;
else if (this.weight == anotherCat.weight&&(this.age == anotherCat.age||this.strength == anotherCat.strength))
return false;
else if (this.age == anotherCat.age&&(this.weight == anotherCat.weight||this.strength == anotherCat.strength))
return false;
else if (this.strength == anotherCat.strength&&(this.age == anotherCat.age||this.strength == anotherCat.strength))
return false;
else
return false;*/