Коллеги, что не так реализовано ? не проходит условие fight, выводил отдельный print на равность событий все сходиться ....
package com.javarush.task.task05.task0502;
/*
Реализовать метод fight
*/
public class Cat {
public int age;
public int weight;
public int strength;
//public String name;
public Cat() {
}
public boolean fight(Cat anotherCat) {
//напишите тут ваш код
int cat_a=0,cat_b=0;
if (this.age>anotherCat.age){
cat_a++;
return true;}
else
if (this.age<anotherCat.age){
cat_b++;
return false; }
if (this.weight>anotherCat.weight){
cat_a++;
return true;}
else
if (this.weight<anotherCat.weight) {
cat_b++;
return false; }
if (this.strength>anotherCat.strength){
cat_a++;
return true; }
else
if (this.strength<anotherCat.strength){
cat_b++;
return false; }
if (cat_a>cat_b)
return true;
else
return false;
}
public static void main(String[] args) {
Cat cat1 = new Cat();
//cat1.name = "Васька";
cat1.age =8;
cat1.weight =10;
cat1.strength = 6;
Cat cat2 = new Cat();
//cat2.name = "Тимка";
cat2.age = 9;
cat2.weight = 9;
cat2.strength = 12;
if (cat1.fight(cat2)) {
System.out.println("Васька"+" "+"WIN");
System.out.println("Тимка"+" "+"LOSE"); }
else
if (cat2.fight(cat1)) {
System.out.println("Тимка"+" "+"WIN");
System.out.println("Васька"+" "+"LOSE"); }
//else
//if (cat1.fight(cat2)==cat2.fight(cat1))
//System.out.println("Ничья");
}
}