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) {
Cat cat1 = new Cat();
Cat cat2 = new Cat();
cat1.age = 13;
cat1.weight = 15;
cat1.strength = 18;
cat2.age = 9;
cat2.weight = 13;
cat2.strength = 11;
int k1 = 0;
int k2 = 0;
if (this.age>anotherCat.age){k1++;}
else if (this.age<anotherCat.age){k2++;}
else if (this.weight>anotherCat.weight){k1++;}
else if (this.weight<anotherCat.weight){k2++;}
else if (this.strength>anotherCat.strength){k1++;}
else if (this.strength<anotherCat.strength){k2++;}
else if (this.age == anotherCat.age){k1++; k2++;}
else if (this.weight == anotherCat.weight){k1++; k2++;}
else if (this.strength == anotherCat.strength){k1++; k2++;}
if (k1>k2){
cat1.fight(cat2);
return true;
}
else if (k2>k1){
cat2.fight(cat1);
return true;
}
else if (k1==k2){
cat1.fight(cat2);
cat2.fight(cat1);
return false;
}
else if (k1<k2){
cat1.fight(cat2);
return false;
}
else if (k2<k1){
cat2.fight(cat1);
return false;
}
}
public static void main(String[] args) {
}
}
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) {
Cat cat1 = new Cat();
Cat cat2 = new Cat();
cat1.age = 13;
cat1.weight = 15;
cat1.strength = 18;
cat2.age = 9;
cat2.weight = 13;
cat2.strength = 11;
int k1 = 0;
int k2 = 0;
if (this.age>anotherCat.age){k1++;}
else if (this.age<anotherCat.age){k2++;}
else if (this.weight>anotherCat.weight){k1++;}
else if (this.weight<anotherCat.weight){k2++;}
else if (this.strength>anotherCat.strength){k1++;}
else if (this.strength<anotherCat.strength){k2++;}
else if (this.age == anotherCat.age){k1++; k2++;}
else if (this.weight == anotherCat.weight){k1++; k2++;}
else if (this.strength == anotherCat.strength){k1++; k2++;}
if (k1>k2){
cat1.fight(cat2);
return true;
}
else if (k2>k1){
cat2.fight(cat1);
return true;
}
else if (k1==k2){
cat1.fight(cat2);
cat2.fight(cat1);
return false;
}
else if (k1<k2){
cat1.fight(cat2);
return false;
}
else if (k2<k1){
cat2.fight(cat1);
return false;
}
}
public static void main(String[] args) {
}
}