Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Cat {
- public String name;
- private int age;
- private int weight;
- private int end;
- private int speed;
- private int ag;
- private int power;
- private double hp;
- private int strength;
- private double armor;
- private int intel;
- public Cat(String name,int age,int weight, int ag, int strength, int intel){
- this.name = name;
- this.intel = intel;
- this.strength = strength;
- this.ag = ag;
- this.age = age;
- this.speed=ag/age;
- this.weight = weight;
- this.end = strength/weight;
- this.power = weight*speed*intel;
- this.armor = strength*ag/10;
- if (age<6){
- this.hp = weight*age*end;
- }else if (age<12){
- this.hp = weight*(age/4)*end;
- }else
- this.hp = weight*(age/10)*end;
- }
- public void heal(){
- this.hp=this.weight*this.end*this.age;
- }
- public Cat fight(Cat anotherCat){
- double power = this.power*anotherCat.armor;
- double anotherPower = anotherCat.power*this.armor;
- while (this.hp>0 && anotherCat.hp>0){
- this.hp = this.hp-anotherPower;
- anotherCat.hp = anotherCat.hp-power;
- }
- this.age=this.age+1;
- anotherCat.age=anotherCat.age+1;
- if (this.hp<0){
- anotherCat.intel=anotherCat.intel+1;
- return anotherCat;
- }else
- this.intel=this.intel+1;
- return this;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement