Вроде бы удовлетворяет условиям задачи, но проверку не проходит. Есть у кого какие мысли?
Изменил условия, но все равно не проходит решение
public class Cat {
public int age;
public int weight;
public int strength;
public Cat() {
}
public boolean fight(Cat anotherCat) {
int win = 0;
boolean res = false;
if (this.age > anotherCat.age)
win++;
if (this.weight > anotherCat.weight)
win++;
if (this.strength > anotherCat.strength)
win++;
if (win >= 1)
res = true;
return res;
}
public static void main(String[] args) {
Cat bo = new Cat();
Cat mo = new Cat();
bo.age = 10;
bo.weight = 1;
bo.strength = 1;
mo.age = 1;
mo.weight = 1;
mo.strength = 1;
if (bo.fight(mo) & !mo.fight(bo))
System.out.println("1 win");
else if (!bo.fight(mo) & mo.fight(bo))
System.out.println("2 win");
else
System.out.println("tie");
}
}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 win = 0;
if (this.age > anotherCat.age)
win++;
else
win--;
if (this.weight > anotherCat.weight)
win++;
else
win--;
if (this.strength > anotherCat.strength)
win++;
else
win--;
if (win > 0)
return true;
else
return false;
}
public static void main(String[] args) {
Cat bo = new Cat();
Cat mo = new Cat();
bo.age = 15;
bo.weight = 16;
bo.strength = 15;
mo.age = 10;
mo.weight = 12;
mo.strength = 16;
bo.fight(mo);
mo.fight(bo);
if (bo.fight(mo) && !mo.fight(bo))
System.out.println("1 win");
else if (!bo.fight(mo) && mo.fight(bo))
System.out.println("2 win");
else
System.out.println("tie");
}
}