So...if the main program is creating its own cats with the proper setup to return true for Cat1 and false for Cat2, I'm curious as to how the testing program is failing to verify. Is it substituting its own main with some other Cat objects? In short, even after reading the other comments, I can't figure out how to implement how cat2 loses out to cat1 (other than cat1.fight(cat2) returning true based on the if conditions).
package com.codegym.task.task05.task0502;
/*
Implement the fight method
*/
public class Cat {
public int weight;
public int age;
public int strength;
public Cat() {
}
public boolean fight(Cat anotherCat) {
if ((this.weight < anotherCat.weight && this.age < anotherCat.age) || this.strength > anotherCat.strength)
return true;
else
return false;
}
public static void main(String[] args) {
Cat cat1 = new Cat();
cat1.age = 2;
cat1.weight = 13;
cat1.strength = 78;
Cat cat2 = new Cat();
cat2.age = 13;
cat2.weight = 26;
cat2.strength = 23;
System.out.println(cat1.fight(cat2));
}
}