im lost about the `this` keyword, in the boolean method it is right to think that the value of `this.age` is reference of the age of Cat class and the the value of `age` is the value of cat2 age? if yes how we reference if we have a cat3 object? i see some people using anotherCat.age to point the difference but anotherCat is just a replaceable variable right? plz help and thanks :D! and by the way im lost at the last condition too!! :(
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) {
if(this.age == age && this.weight == weight && this.strength == strength){
return true;
}
else{
return false;
}
//write your code here
}
public static void main(String[] args) {
Cat cat1 = new Cat();
cat1.age = 5;
cat1.weight = 6;
cat1.strength = 7;
Cat cat2 = new Cat();
cat2.age = 5;
cat2.weight = 6;
cat2.strength = 7;
System.out.print(cat1.fight(cat2));
}
}