Мяу?
package com.javarush.task.task05.task0502;
/*
Реализовать метод fight
если cat1.fight(cat2) возвращает true,
то cat2.fight(cat1) должен возвращать false.
*/
public class Cat {
public int age;
public int weight;
public int strength;
public Cat() {
}
public boolean fight(Cat anotherCat) {
//напишите тут ваш код
int i=0;
if(this.age>anotherCat.age) i++;
if(this.strength>anotherCat.strength) i++;
if(this.weight>anotherCat.weight) i++;
return i >= 2;
}
public static void main(String[] args) {
Cat cat1 = new Cat();
cat1.weight=10;cat1.age=5;cat1.strength=12;
Cat cat2 = new Cat();
cat2.weight=9;cat2.age=6;cat2.strength=11;
// System.out.println(cat1.fight(cat2)); //true
// System.out.println(cat1.fight(cat2)); //true
// System.out.println(cat1.fight(cat1)); //false
// System.out.println(cat2.fight(cat1)); //false
// System.out.println(cat2.fight(cat1)); //false
// System.out.println(cat2.fight(cat2)); //false
}
}