the code runs fine for when the values of the two objects are different, but when they are same, it returns true for both the below statements;
System.out.println(cat1.fight(cat2));
System.out.println(cat2.fight(cat1));
It should return true for one and false for the other. I can use "this.equals(anotherCat)" to check if the class variables are same, but what do I do to return separate values?
package com.codegym.task.task05.task0502;
/*
Implement the fight method
*/
public class Cat {
public int age;
public int weight;
public int strength;
public Cat() {
}
public boolean fight(Cat anotherCat) {
//write your code here
if ((this.age <= anotherCat.age) && (this.weight >= anotherCat.weight) && (this.strength >= anotherCat.strength))
return true;
else
return false;
}
public static void main(String[] args) {
}
}