day11-类作为成员变量类型(hero,weapon,armor)

This commit is contained in:
2026-07-28 14:01:25 +08:00
parent ab1a4ed32b
commit 0d1d53cc68
4 changed files with 166 additions and 0 deletions
@@ -0,0 +1,27 @@
package com.inmind.class_interface04;
//防御装类
public class Armor {
private String name;//防御装的名字
private int protectNum;//防御力
public Armor(String name, int protectNum) {
this.name = name;
this.protectNum = protectNum;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getProtectNum() {
return protectNum;
}
public void setProtectNum(int protectNum) {
this.protectNum = protectNum;
}
}