SHARE
TWEET

Untitled

a guest Sep 18th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.javarush.task.task05.task0502;
  2.  
  3. /*
  4. Реализовать метод fight
  5. */
  6.  
  7. public class Cat {
  8.     public int age;
  9.     public int weight;
  10.     public int strength;
  11.    
  12.  
  13.     public Cat() {
  14.     }
  15.    
  16.     public Cat(int age, int weight, int strength) {
  17.     }
  18.  
  19.     public boolean fight(Cat anotherCat) {
  20.         //напишите тут ваш код
  21.         int x = 0;
  22.         if (this.age > anotherCat.age) {
  23.             x++;
  24.         }
  25.         else {
  26.             x--;
  27.         }
  28.         if (this.weight > anotherCat.weight) {
  29.             x++;
  30.         }
  31.         else {
  32.             x--;
  33.         }
  34.         if (this.strength > anotherCat.strength) {
  35.             x++;
  36.         }
  37.         else {
  38.             x--;
  39.         }
  40.         if (x >= 1) {
  41.             return true;
  42.         }
  43.         else {
  44.             return false;
  45.         }
  46.  
  47.     }
  48.    
  49. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top