Skip to content

Instantly share code, notes, and snippets.

@mib32
Last active August 29, 2015 14:18
Show Gist options
  • Save mib32/65c3aba1008d292933c0 to your computer and use it in GitHub Desktop.
Save mib32/65c3aba1008d292933c0 to your computer and use it in GitHub Desktop.
/*
Реализовать метод boolean fight(Cat anotherCat): реализовать механизм драки котов в зависимости от их веса, возраста и силы. Зависимость придумать самому. Метод должен определять, выиграли ли мы (this) бой или нет, т.е. возвращать true, если выиграли и false - если нет. Должно выполняться условие: если cat1.fight(cat2) = true , то cat2.fight(cat1) = false/
*/
public class Cat
{
public String name;
public int age;
public int weight;
public int strength;
public Cat()
{
}
private int strike()
{
int strike = self.age + self.weight + self.strength;
return strike;
}
public boolean fight (Cat anotherCat)
{
boolean result = this.strike > anotherCat.strike;
return result; //Напишите тут ваш код
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment