Долго ковырялся, пробовал счетчики, то работало все, то ничего, но я не сдаюсь.
А вот валидатор кажется решил сдаться на мне,
ведь в одном случае ему нравилось все, кроме "честности" боев (считал что у меня не работает механизм сравнения параметров),
в другом случае ему не нравилось условие "ничьей" (хотя все работало как часы)
Но теперь он просто отказывается верить в то, что у меня есть метод fight в принципе. Помогите мне сделать валидатору приятно, пожалуйста😢😢😢
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 win1 = 0;
int win2 = 0;
if (this.age > anotherCat.age){
win1++;
}
else if (this.age < anotherCat.age){
win2++;
}
if (this.weight > anotherCat.weight){
win1++;
}
else if(this.weight < anotherCat.weight){
win2++;
}
if (this.strength > anotherCat.strength){
win1++;
}
else if(this.strength < anotherCat.strength){
win2++;
}
if (win1 > win2){
System.out.println(win1 + "<-1 2->" + win2);
return true;
}
else if (win2 > win1){
System.out.println(win2 + "<-2 1->" + win1);
return false;
}
else {return false;}
}
public static void main(String[] args) {
Cat cat1 = new Cat();
cat1.age = 1;
cat1.weight = 2;
cat1.strength = 1;
Cat cat2 = new Cat();
cat2.age = 1;
cat2.weight = 2;
cat2.strength = 1;
System.out.println(cat1.fight(cat2));
}
}