请问各位下列程序怎么改运行的了?
李伟豪 2019-04-14 06:16:25 声明一个水浒人物类,其数据成员为:人物名称,排位号码, (利用静态变量实现自动编号)、人物简介,武力值
//在构造方法中利用此静态变量为对象的编号赋值,
//在主方法中定义对象数组,并将水浒的前10名人物输出。
class Shuihu {
private String name;//名称
private int number;//号码
private String introduction;//人物简介
private double harm;//武力值
static int count = 0;
// 在构造方法中利用此静态变量为对象的编号赋值
public Shuihu(){
count++;
this.number=count;
}
public Shuihu(String name,int number,String introduction,double harm) {
this();
this.name = name;
this.number =number;
this. introduction=introduction ;
this.harm=harm;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
public String getIntroduction() {
return introduction;
}
public void setIntroduction(String introduction) {
this.introduction = introduction;
}
public double getHarm() {
return harm;
}
public void setHarm(double harm) {
this.harm = harm;
}
public static int getCount() {
return count;
}
public static void setCount(int count) {
Shuihu.count = count;
}
public String getInfo() {
return "排位:" + this.number + "名称:" + this.name+ "简介:" + this.introduction + "伤害值:" + this.harm;
}
}
public class XIXI {
public static void main(String[] args) {
Shuihu shuihu[] = new Shuihu[10];
shuihu[0] = new Shuihu ("宋江","天魁星", 100);
shuihu[1] = new Shuihu("卢俊义","玉麒麟", 100);
shuihu[2] = new Shuihu("吴用","智多星", 100);
shuihu[3] = new Shuihu("公孙胜","入云龙", 100);
shuihu[4] = new Shuihu("关胜","大刀", 100);
shuihu[5] = new Shuihu("林冲","豹子头", 100);
shuihu[6] = new Shuihu("秦明","霹雳火", 100);
shuihu[7] = new Shuihu("呼延灼","天威星", 100);
shuihu[8] = new shuihu("花荣","小李广", 100);
shuihu[9] = new shuihu("柴进","小旋风", 100);
for (int i = 0; i <= shuihu.length - 1; i++) {
System.out.println(shuihu[i].getInfo());
}
}
}