ΠΠΎΠ΄ΡΠΊΠ°ΠΆΠΈΡΠ΅, ΠΏΠΎΡΠ΅ΠΌΡ Π½Π΅ ΠΏΡΠΎΡ
ΠΎΠ΄ΠΈΡ ΠΏΡΠΎΠ²Π΅ΡΠΊΡ?
package com.javarush.task.task05.task0502;
/*
Π Π΅Π°Π»ΠΈΠ·ΠΎΠ²Π°ΡΡ ΠΌΠ΅ΡΠΎΠ΄ fight
*/
public class Cat {
public int age;
public int weight;
public int strength;
public Cat() {
}
public boolean fight(Cat anotherCat) {
//Π½Π°ΠΏΠΈΡΠΈΡΠ΅ ΡΡΡ Π²Π°Ρ ΠΊΠΎΠ΄
boolean fightResult = true;
int catParameters = 0;
if (this.age > anotherCat.age)
catParameters++;
if (this.weight > anotherCat.weight)
catParameters++;
if (this.strength > anotherCat.strength)
catParameters++;
if(catParameters < 2)
fightResult = false;
return fightResult;
}
public static void main(String[] args) {
}
}