public class Cat {
public int age;
public int weight;
public int strength;
public int point=0;
public Cat() {
}
public boolean fight(Cat anotherCat) {
//write your code here
if(this.age>=anotherCat.age)
point++;
else if(this.weight<=anotherCat.weight)
point++;
else if(this.strength>=anotherCat.strength)
point++;
if(this.point >= anotherCat.point)
return true;
else
return false;
}
public static void main(String[] args) {
Cat cat1 = new Cat();
Cat cat2 = new Cat();
cat1.strength = 10;
cat1.weight = 15;
cat1.age = 15;
System.out.println(cat1.fight(cat2));
cat2.strength = 5;
cat2.weight = 16;
cat2.age = 14;
System.out.println(cat2.fight(cat1));
}
}
package com.codegym.task.task05.task0502;
/*
Implement the fight method
*/
public class Cat {
public int age;
public int weight;
public int strength;
public int point=0;
public Cat() {
this.age = age;
this.weight = weight;
this.strength = strength;
}
public boolean fight(Cat anotherCat) {
//write your code here
if(this.age>=anotherCat.age)
point++;
else if(this.weight<=anotherCat.weight)
point++;
else if(this.strength>=anotherCat.strength)
point++;
if(this.point >= anotherCat.point)
return true;
else
return false;
}
public static void main(String[] args) {
Cat cat1 = new Cat();
Cat cat2 = new Cat();
cat1.strength = 10;
cat1.weight = 15;
cat1.age = 15;
System.out.println(cat1.fight(cat2));
cat2.strength = 5;
cat2.weight = 16;
cat2.age = 14;
System.out.println(cat2.fight(cat1));
}
}