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 thisCatPoints = 0;
if (anotherCat.age < this.age) thisCatPoints = thisCatPoints + 1;
if (anotherCat.strength < this.strength) thisCatPoints = thisCatPoints + 1;
if (anotherCat.weight < this.weight) thisCatPoints = thisCatPoints + 1;
if (thisCatPoints > 0) return true;
else return false;
}
public static void main(String[] args) {
Cat catVaska = new Cat();
catVaska.weight = 16;
catVaska.age = 1;
catVaska.strength = 4;
Cat catBarsik = new Cat();
catBarsik.strength = 4;
catBarsik.weight = 15;
catBarsik.age = 1;
System.out.println(catBarsik.fight(catVaska));
System.out.println(catVaska.fight(catBarsik));
}
}
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 thisCatPoints = 0;
if (anotherCat.age < this.age) thisCatPoints = thisCatPoints + 1;
if (anotherCat.strength < this.strength) thisCatPoints = thisCatPoints + 1;
if (anotherCat.weight < this.weight) thisCatPoints = thisCatPoints + 1;
if (thisCatPoints > 0) return true;
else return false;
}
public static void main(String[] args) {
Cat catVaska = new Cat();
catVaska.weight = 16;
catVaska.age = 1;
catVaska.strength = 4;
Cat catBarsik = new Cat();
catBarsik.strength = 4;
catBarsik.weight = 15;
catBarsik.age = 1;
System.out.println(catBarsik.fight(catVaska));
System.out.println(catVaska.fight(catBarsik));
}
}