Подскажите пожалуйста, в чем может быть проблема.
И почему-то работает еще хуже, если использую один счетчик i1 и просто прибавляю или уменьшаю значение.
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 i1 = 0;
int i2 = 0;
if (this.age >= anotherCat.age)
{
if (this.age == anotherCat.age)
i1 = 0;
else
i1++;
}
else if (this.age < anotherCat.age)
i2++;
if (this.weight >= anotherCat.weight)
{
if (this.weight == anotherCat.weight)
i1 = 0;
else
i1++;
}
else if (this.weight < anotherCat.weight)
i2++;
if (this.strength >= anotherCat.strength)
{
if (this.strength == anotherCat.strength)
i1 = 0;
else
i1++;
}
else if (this.strength < anotherCat.strength)
i2++;
if (i1 > i2)
return true;
else
return false;
}
public static void main(String[] args) {
}
}