Advertisement
Guest User

Untitled

a guest
Aug 24th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.39 KB | None | 0 0
  1. public class Cat {
  2.      public String name;
  3.         private int age;
  4.         private int weight;
  5.         private int end;
  6.         private int speed;
  7.         private int ag;
  8.         private int power;
  9.         private double hp;
  10.         private int strength;
  11.         private double armor;
  12.         private int intel;
  13.         public Cat(String name,int age,int weight,   int ag, int strength, int intel){
  14.         this.name = name;
  15.         this.intel = intel;
  16.         this.strength = strength;
  17.         this.ag = ag;
  18.         this.age = age;
  19.         this.speed=ag/age;
  20.         this.weight = weight;
  21.         this.end = strength/weight;
  22.         this.power = weight*speed*intel;
  23.         this.armor = strength*ag/10;
  24.         if (age<6){
  25.         this.hp = weight*age*end;
  26.         }else if (age<12){
  27.             this.hp = weight*(age/4)*end;
  28.         }else
  29.             this.hp = weight*(age/10)*end;
  30.        
  31.     }
  32.         public void heal(){
  33.             this.hp=this.weight*this.end*this.age;
  34.         }
  35.         public  Cat fight(Cat anotherCat){
  36.             double power = this.power*anotherCat.armor;
  37.             double anotherPower = anotherCat.power*this.armor;
  38.             while (this.hp>0 && anotherCat.hp>0){
  39.                 this.hp = this.hp-anotherPower;
  40.                 anotherCat.hp = anotherCat.hp-power;
  41.             }
  42.             this.age=this.age+1;
  43.             anotherCat.age=anotherCat.age+1;
  44.             if (this.hp<0){
  45.                 anotherCat.intel=anotherCat.intel+1;
  46.                 return anotherCat;
  47.             }else
  48.                 this.intel=this.intel+1;
  49.                 return this;
  50.         }
  51.    
  52.        
  53.    
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement