Π½Π΅ ΠΏΡΠΎΡ
ΠΎΠ΄ΠΈΡ ΡΡΠ»ΠΎΠ²ΠΈΠ΅
package com.javarush.task.task05.task0502;
/*
Π Π΅Π°Π»ΠΈΠ·ΠΎΠ²Π°ΡΡ ΠΌΠ΅ΡΠΎΠ΄ fight
*/
public class Cat {
public int age;
public int weight;
public int strength;
public Cat() { }
public Cat(int age, int weight, int strength){
this.age = age;
this.weight = weight;
this.strength = strength;
}
public boolean fight(Cat anotherCat) {
//Π½Π°ΠΏΠΈΡΠΈΡΠ΅ ΡΡΡ Π²Π°Ρ ΠΊΠΎΠ΄
int a = 0;
int b = 0;
int c = 0;
if(Integer.compare(age, anotherCat.age)==1){a = 1;}
if(Integer.compare(weight, anotherCat.weight)==1){b = 1;}
if(Integer.compare(strength, anotherCat.strength)==1){c = 1;}
int d = a + b + c;
// System.out.println(d);
if(d>=2)return true;
else
return false;
}
public static void main(String[] args) {
Cat cat = new Cat(1,1,1);
Cat cat1 = new Cat(2,2,2);
System.out.println(cat.fight(cat1));
System.out.println(cat1.fight(cat));
}
}