Last active
August 29, 2015 14:18
-
-
Save mib32/65c3aba1008d292933c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Реализовать метод 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