Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.javarush.task.task05.task0502;
- /*
- Реализовать метод fight
- */
- public class Cat {
- public int age;
- public int weight;
- public int strength;
- public Cat() {
- }
- public Cat(int age, int weight, int strength) {
- }
- public boolean fight(Cat anotherCat) {
- //напишите тут ваш код
- int x = 0;
- if (this.age > anotherCat.age) {
- x++;
- }
- else {
- x--;
- }
- if (this.weight > anotherCat.weight) {
- x++;
- }
- else {
- x--;
- }
- if (this.strength > anotherCat.strength) {
- x++;
- }
- else {
- x--;
- }
- if (x >= 1) {
- return true;
- }
- else {
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement