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 score1=0;
int score2=0;
if (this.weight >= anotherCat.weight){
score1++;
} else {
score2++;
}
if (this.age >= anotherCat.age){
score1++;
} else {
score2++;
}
if (this.strength >= anotherCat.strength){
score1++;
} else {
score2++;
}
return score1<=score2;
}
public static void main(String[] args) {
}
}
Николай Макаренко
25 уровень
Так. Прошлый вопрос был неудачный. А этот более удачный. Все равно не понимать почему не проходит проверку.
Решен
Комментарии (2)
- популярные
- новые
- старые
Для того, чтобы оставить комментарий Вы должны авторизоваться
Руслан
24 февраля 2020, 21:56решение
в 22 строке else if (this.weight != anotherCat.weight) score2++;
в 28 строке else if (this.age != anotherCat.age) score2++;
в 36 строке else if (this.strength != anotherCat.strength) score2++;
if (a > b) return true;
else return false;
И первым у меня Age, потом Weight, потом Strength, ифы все без фигурных скобок, и вместо >= везде знак >
Удачи!
+2
Руслан
24 февраля 2020, 21:57
a - это score1, ну а b - это ...
0