发表日期: 2022-03-23 09:44:39 浏览次数:100
阜阳网页制作

public class Hero { String name; //名字 int attackDamage; //物理攻击 int abilityPower; //法术强度 int armor; //护甲 int magicResistance; //魔抗 float attackSpeed; //攻击速度 int cooldownReduction; //冷却缩减 int criticalStrike; //暴击率 int moveSpeed; //移动速度 int hp; //血量 int mp; //蓝量}除了属性,英雄还有行为。比如拆塔,坑队友,K头,跳舞等。
public class Hero {
public void DestroyTower(){
System.out.println("正在拆塔");
}
public void Keng(){
System.out.println("坑了一下队友");
}
public void Kb(){
System.out.println("抢到了一个人头");
}
public void Dance(){
System.out.println("正在跳舞");
}}对象就是指具体的英雄,比如德玛(garen)。就可以在 main 方法中 new 一个对象。
public static void main(String[] args) { Hero garen = new Hero(); garen.name = "盖伦"; garen.attackDamage = 71; garen.abilityPower = 0; garen.armor = 36; garen.magicResistance = 32; garen.attackSpeed = 0.69f; garen.cooldownReduction = 0; garen.criticalStrike = 0; garen.moveSpeed = 350; garen.hp = 600; garen.mp = 0;}