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;
}
}
}
RAW Paste Data
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;
}
}
}
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;
}
}
}