Only the Cat class proceeds with tick and the rest of the task conditions fail. code works fine with cat1 fighting cat2 results returns true and so on with fight boolean statment..my question is how do i modify this code to suit the task?
package com.codegym.task.task05.task0502;
/*
Implement the fight method
*/
public class Cat {
public int age;
public int weight;
public int strength;
public Cat(int weight, int age, int strength) {
// Cat anotherCat = new Cat(this);
this.age = age;
this.weight = weight;
this.strength = strength;
}
public boolean fight(Cat anotherCat) {
//write your code here
if(age<anotherCat.age){
return true;
}
else
return false;
}
public static void main(String[] args) {
Cat cat1= new Cat(25,10,65);
/* cat1. age = 10;
cat1.weight = 25;
cat1.strength = 65; */
Cat cat2 = new Cat(10,12,15);
/* cat2.age = 10;
cat2.weight = 12;
cat2.strength = 15; */
System.out.println(cat2.fight(cat1));
System.out.println(cat1.fight(cat2));
}
}