не могу понять чего он хочет?
на валидации не пропускает, ошибка:
Нужно сравнить каждый критерий по отдельности, и победителем будет тот, у которого больше "победивших" критериев.
код:
public boolean fight(Cat anotherCat) {
//напишите тут ваш код
int i = 0;
boolean a = this.age > anotherCat.age ? true : false;
if(a==true){i++;}
boolean b = this.weight > anotherCat.weight ? true : false;
if(b==true){i++;}
boolean c = this.strength > anotherCat.strength ? true : false;
if(c==true){i++;}
return (i>1);
}
перепробовал разные способы. Только запутался совсем. Кто поможет объяснить?
С другими задачами до этого с проблемами не сталкивался. Все решал довольно легко.
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 i = 0;
boolean a = this.age > anotherCat.age ? true : false;
if(a==true){i++;}
boolean b = this.weight > anotherCat.weight ? true : false;
if(b==true){i++;}
boolean c = this.strength > anotherCat.strength ? true : false;
if(c==true){i++;}
return (i>1);
}
public static void main(String[] args) {
}
}