I use a counter to give points based on the stats. Why is it not working?
package com.codegym.task.task05.task0502;
/*
Implement the fight method
*/
public class Cat {
public int age;
public int weight;
public int strength;
public int x =0;
public Cat() {
}
public boolean fight(Cat anotherCat) {
//write your code here
int points = 0;
if (this.age <= anotherCat.age){
points++;
}else if (this.weight >= anotherCat.weight){
points++;
}else if (this.strength >= anotherCat.strength){
points++;}
if (points>=2)
return true;
else
return false;
}
public static void main(String[] args) {
Cat cat1 = new Cat();
Cat cat2 = new Cat();
cat1.age = 12;
cat2.age = 11;
cat1.weight = 24;
cat2.weight = 23;
cat1.strength = 99;
cat2.strength = 98;
System.out.println(cat1.fight(cat2));
System.out.println(cat2.fight(cat1));
}
}