The task conditions are too vague to understand why my solution doesn't work =\
package en.codegym.task.jdk13.task05.task0501;
/*
Cat carnage (1)
*/
public class Solution {
public static void main(String[] args) {
Cat cat1 = new Cat("cat1", 1, 10, 5);
Cat cat2 = new Cat("cat2", 1, 10, 5);
Cat cat3 = new Cat("cat3", 1, 10, 5);
}
public static class Cat {
//write your code here
private String name;
private int age;
private int weight;
private int strength;
public Cat(String name, int age, int weight, int strength) {
this.name = name;
this.age = age;
this.weight = weight;
this.strength = strength;
}
public boolean fight(Cat cat2) {
int cat1points = 0;
int cat2points = 0;
//youngest cat gets a point
if (this.age < cat2.age)
cat1points++;
else if (this.age > cat2.age)
cat2points++;
//heaviest cat gets a point
if (this.weight > cat2.weight)
cat1points++;
else if (this.weight < cat2.weight)
cat2points++;
//strongest cat gets a point
if (this.strength > cat2.strength)
cat1points++;
else if (this.strength < cat2.strength)
cat2points++;
//returns false if there's a tie
if (cat1points > cat2points)
return true;
else
return false;
}
}
}