Hello guys. I have code in the bottom and tried firstly to compare the weight, age and strength. After tried compare only strength. But in both of the cases don't meet the 3rd and 6th requirements
package en.codegym.task.jdk13.task05.task0501;
/*
Cat carnage (1)
*/
public class Solution {
public static void main(String[] args) {
Cat cat1 = new Cat("Kitty", 42, 3, 5);
Cat cat2 = new Cat("Cat", 4, 2, 5);
Cat cat3 = new Cat("Tom", 4, 2, 5);
System.out.println(cat1.fight(cat2));
System.out.println(cat2.fight(cat3));
}
public static class Cat {
private String name;
private int age;
private int weight;
private int strength;
public Cat(String name, int age, int weight, int strength){
this.name = name;
this.age = age;
this.weight = weight;
this.strength = strength;
}
public boolean fight(Cat anotherCat){
int currentCat = 0;
int fightingCat = 0;
if(strength > anotherCat.strength){
currentCat++;
}
else if(strength < anotherCat.strength){
fightingCat++;
}
boolean res = (currentCat <= fightingCat) ? false : true;
return res;
}
public String getName(){
return name;
}
public int getAge(){
return age;
}
public int getWeight(){
return weight;
}
public int getStrength(){
return strength;
}
}
}