简单定义一个人类 简单的输出
public class People {
double height;
int age;
int sex;
String name;
public People(int h,int a,int s,String n){
height = h;
age = a;
sex = s;
name = n;
}
public double getheight(){
return height;
}
public void setheight(double newheight){
height = newheight;
}
void cry(){
System.out.println("I'm crying");
}
void laugh(){
System.out.println("I'm laughing");
}
void printbase(){
System.out.println("我是-"+name);
System.out.println("我的身高是:"+height+"cm");
System.out.println("我的年龄是:"+age+"岁");
if (this.sex==0){
System.out.println("我是男生");
}
else
System.out.println("我是女生");
}
public static void main(String[] args) {
People czz= new People(0,0,0,"czz");
czz.height=165;
czz.age=19;
czz.sex=1;
czz.laugh();
czz.printbase();
People cxa = new People(171,19,0,"cxa");
cxa.laugh();
cxa.printbase();
People lilei = new People(0,0,0,"lilei");
lilei.setheight(170);
System.out.print("lilei的身高是"+lilei.getheight());
}
}