package com.hanqi.test; public class xiyoujirenwu {
private double height;// 身高 private String name;// 名称 private String weapon;// 武器 public double getHeight() {
return height;
} public void setHeight(double height) {
if(height<=10)
{
System.out.println("身高输入有误");
}
this.height = height;
} public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} public String getWeapon() {
return weapon;
} public void setWeapon(String weapon) {
this.weapon = weapon;
}
package com.hanqi.test; public class Test04 { public static void main(String[] args) { xiyoujirenwu swk=new xiyoujirenwu();
swk.setName("孙悟空");
System.out.println("人物"+swk.getName());
swk.setHeight();
System.out.println("身高:"+swk.getHeight());
} }