Смотрел решения других, вроде всё также, но не проходит! Что не так, помогите пожалуйста!
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 ct = 0;
int ca = 0;
if (anotherCat.age > this.age)
ca++;
else if (anotherCat.age < this.age)
ct++;
// else {ca++; ct++;}
if (anotherCat.weight > this.age)
ca++;
else if (anotherCat.weight < this.age)
ct++;
// else {ca++; ct++;}
if (anotherCat.strength > this.strength)
ca++;
else if (anotherCat.strength < this.strength)
ct++;
// else {ca++; ct++;}
if (ct <= ca)
return false;
else
return true;
}
public static void main(String[] args) {
Cat q = new Cat();
q.age = 2;
q.weight = 2;
q.strength = 2;
Cat a = new Cat();
a.age = 2;
a.weight = 2;
a.strength = 5;
System.out.println(q.fight(a));
System.out.println(a.fight(q));
}
}