сломал голову
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) {
//напишите тут ваш код
Cat cat1 = new Cat();
cat1.age = 10;
cat1.weight = 6;
cat1.strength = 7;
Cat cat2 = new Cat();
cat2.age = 8;
cat2.weight = 4;
cat2.strength = 9;
int cat1Score = 0;
int cat2Score = 0;
if (this.age > anotherCat.age) {
cat1Score++;
} else if (anotherCat.age > this.age) {
cat2Score++;
}
if (this.weight > anotherCat.weight) {
cat1Score++;
} else if (anotherCat.weight > this.weight) {
cat2Score++;
}
if (this.strength > anotherCat.strength) {
cat1Score++;
} else if (anotherCat.strength > this.strength) {
cat2Score++;
} else if (this.age == anotherCat.age) {
cat1Score++;
cat2Score++;
} else if (this.weight == anotherCat.weight) {
cat1Score++;
cat2Score++;
} else if (this.strength == anotherCat.strength) {
cat1Score++;
cat2Score++;
}
return cat1Score>cat1Score;
}
public static void main(String[] args) {
}
}