该楼层疑似违规已被系统折叠隐藏此楼查看此楼
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;
}
}
如果觉得《java我现在不懂看不懂 看都看不懂 难道我与Java无缘吗》对你有帮助,请点赞、收藏,并留下你的观点哦!