public class Cat {
public int age;
public int weight;
public int strength;
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) {
int cat1Points = 0;
int cat2Points = 0;
if (this.age > anotherCat.age) {
cat1Points++;
} else if (this.age == anotherCat.age){return false;}
else{
cat2Points++;
}
if (this.strength > anotherCat.strength) {
cat1Points++;
} else if (this.strength== anotherCat.strength){return false;}
else{
cat2Points++;
}
if (this.weight > anotherCat.weight) {
cat1Points++;
} else if (this.weight==anotherCat.weight) {return false;}
else{
cat2Points++;
}
if (cat1Points>cat2Points)
{return true;}
else if(cat1Points==cat2Points)
{return false;}
else {return false;}
}
public static void main (String[]args){
Cat cat1 = new Cat();
cat1.age = 5;
cat1.weight = 4;
cat1.strength = 6;
Cat cat2 = new Cat();
cat2.age = 3;
cat2.weight = 2;
cat2.strength = 1;
System.out.println(cat1.fight(cat2));
System.out.println(cat2.fight(cat1));
}
}
все равно, нет