В методе fight реализовать механизм драки котов в зависимости от их веса, возраста и силы согласно условию.
package com.javarush.task.jdk13.task05.task0501;
/*
Кошачья бойня(1)
*/
public class Solution {
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.setName(name);
this.setAge(age);
this.setWeight(weight);
this.setStrength(strength);
}
public boolean fight(Cat anotherCat){
int count = 0;
if (getAge() > anotherCat.getAge()){
count++;
} else {
count--;
}
if (getWeight() > anotherCat.getWeight()){
count ++;
} else {
count--;
}
if (getStrength() > anotherCat.getStrength()){
count ++;
} else {
count--;
}
if (count > 0){
return true;
} else{
return false;
}
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public int getWeight() {
return weight;
}
public void setWeight(int weight) {
this.weight = weight;
}
public int getStrength() {
return strength;
}
public void setStrength(int strength) {
this.strength = strength;
}
}
public static void main(String[] args) {
Cat cat1 = new Cat("eddf", 2, 4, 4);
Cat cat2 = new Cat("fgff", 3, 5, 7);
Cat cat3 = new Cat("hgfd", 6, 3, 6);
}
}