public boolean fight(Cat anotherCat) {
int agePlus = this.age > anotherCat.age ? 1 : 0; //что значит это "1 : 0", как это выполняется программой?
int weightPlus = this.weight > anotherCat.weight ? 1 : 0;
int strengthPlus = this.strength > anotherCat.strength ? 1 : 0;
int score = agePlus + weightPlus + strengthPlus;
return score > 2; // return score > 2 ? true : false;
}
Даниил
12 уровень
Нужно объяснение
Решен
Комментарии (2)
- популярные
- новые
- старые
Для того, чтобы оставить комментарий Вы должны авторизоваться
hidden #1594843
1 сентября 2018, 18:41
this.age > anotherCat.age ? 1 : 0;
===
if(this.age > anotherCat.age) weightPlus = 1; else weightPlus = 0;
+1
Даниил
2 сентября 2018, 12:51
спасибо
0