public class Hero6 {
String name; // 姓名
float hp; // 血量
float armor; // 护甲
int moveSpeed; // 移动速度
public Hero6(String name, float hp) {
this.name = name;
this.hp = hp;
}
public void attack(Hero6 hero6,int damage){
hero6.hp=hero6.hp-damage;
}
public static void main(String[] args) {
Hero6 te=new Hero6("提莫",300);
Hero6 ga=new Hero6("盖伦",600);
//类类型(又叫引用)传参
ga.attack(te, 100);//通过调用ga.attack(te, 100); 使得attack的Hero6 hero6和te这两个引用都指向了同一个对象,都是te引用的那个
System.out.println(te.hp);
System.out.println(ga.hp);
}
}