import org.omg.CORBA.PUBLIC_MEMBER;
public class SixthDay {
public static void main(String[] args) {
Student st = new Student(“小公主”, 22, “女”, 100.00);
st.introduce();
}
}
class Student {
// 定义成员变量
String name;
int age;
String sex;
double score;
// 定义无参构造
public Student() {
System.out.println("定义无参构造");
}
// 定义有参构造
public Student(String name, int age, String sex) {
// 调用构造方法
this();
// 为成员变量赋值
this.name = name;
this.age = age;
this.sex = sex;
}
public Student(String name, int age, String sex, double score) {
// 有参构造
this(name, age, sex);
// this调用成员变量,为成员变量赋值
this.score = score;
}
// 定义成员方法
public void introduce() {
System.out.println("名字是:" + name + " 性别:" + sex + "我的年龄是:" + age);
//调用成员方法
this.introduce1();
}
public void introduce1() {
System.out.println("名字是:" + name + " 性别:" + sex + " 我的年龄是:" + age + " 我的成绩是:" + score);
}
}



