该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
package VIP;
public class Hero {
private String name;
private int Life;
public void hero(String name,int Life){
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getLife() {
return Life;
}
public void setLife(int life) {
Life = life;
}
public static void main(String[] args) {
Hero h=new Hero();
h.setName("李小侠");
h.setLife(300);
Weapon w=new Weapon();
w.setName("死神镰刀");
w.setAttack(12);
Monster m=new Monster();
m.setName("小龟");
m.setLife(300);
m.setType("潜水类");
System.out.println("我是英雄,我的基本属性如下:\n"+"姓名:"+h.getName()+","+"生命力:"+h.getLife());
System.out.println("我是武器,我的基本属性如下:\n"+"武器名:"+m.getName()+","+"攻击力:"+m.getLife());
System.out.println("我是怪物,我的基本属性如下:\n"+"姓名:"+m.getName()+","+"生命力:"+m.getLife()+","+"类型"+m.getType());
}
}
class Weapon{
private String name;
private int attack;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAttack() {
return attack;
}
public void setAttack(int attack) {
this.attack = attack;
}
}
class Monster{
private String name;
private int Life;
privateString type;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getLife() {
return Life;
}
public void setLife(int life) {
Life = life;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}