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