Ребята нид хелп! Пробывал дебажить, почему после второй проверки else if сразу перескакивает на returne?
package com.javarush.task.jdk13.task05.task0501;
/*
Кошачья бойня(1)
*/
public class Solution {
public static class Cat {
private String name;
private int age;
private int weight;
private int strength;
public Cat (String name, int age, int weight, int strength){
this.name = name;
this.age = age;
this.weight = weight;
this.strength = strength;
}
public boolean fight (Cat anotherCat)
{ int b = 0;
int c = 0;
if (age > anotherCat.age)
{
b++;
}
else if (age<=anotherCat.age)
{
c++;
}
else if (weight> anotherCat.weight)
{
b++;
}
else if(weight<=anotherCat.weight)
{
c++;
}
else if(strength>anotherCat.strength)
{
b++;
}
else if (strength<=anotherCat.strength)
{
c++;
}
else if(b>c)
{
return true;
}
return false;
}
}
public static void main(String[] args) {
Cat cat1 = new Cat("Vasya",3,4,15);
Cat cat2 = new Cat("Timka", 3,5,17);
Cat cat3 = new Cat("Boris",3,4,18);
cat2.fight(cat1);
}
}