Не знаю как поместить второй раз код в ранее заданный вопрос, удалил предыдущий. заного залил.
последний пункт с ничьей не проходит, хотя вроде тестирую и дает ответ правильный,
ох уж эти коты
помогите пож-та
package com.javarush.task.task05.task0502;
/*
Реализовать метод fight
*/
public class Cat {
public int age;
public int weight;
public int strength;
public Cat() {
//пустой конструктор
}
public Cat(int age, int weight, int strength) {
this.age = age;
this.weight = weight;
this.strength = strength;
}
public boolean fight(Cat anotherCat) {
int number_of_advantages = 0;
if (anotherCat.age > this.age) {
number_of_advantages++;
}
else if (anotherCat.age < this.age){
number_of_advantages--;
}
if (anotherCat.weight > this.age) {
number_of_advantages++;
}
else if(anotherCat.weight < this.weight){
number_of_advantages--;
}
if (anotherCat.strength > this.strength) {
number_of_advantages++;
}
else if (anotherCat.strength < this.strength){
number_of_advantages--;
}
if (number_of_advantages>=0){
return false;
}
else{
return true;
}
}
public static void main (String[]args){
Cat cat1 = new Cat(2, 2, 6);
Cat cat2 = new Cat(2, 2, 6);
cat1.fight(cat2);
}
}