|
@@ -0,0 +1,84 @@
|
|
|
+package com.lovecoding.day10.oop02this;
|
|
|
+
|
|
|
+/**
|
|
|
+ * ClassName: Student
|
|
|
+ * Package: com.lovecoding.day10.oop02this
|
|
|
+ * Description:
|
|
|
+ *
|
|
|
+ * @Author 爱扣钉-陈晨
|
|
|
+ * @Create 2023/6/18 9:45
|
|
|
+ * @Version 1.0
|
|
|
+ */
|
|
|
+public class Student {
|
|
|
+
|
|
|
+ private String name;
|
|
|
+ private int age;
|
|
|
+ private String address;
|
|
|
+ private boolean sex;
|
|
|
+
|
|
|
+ public Student() {
|
|
|
+ //默认年龄
|
|
|
+ this("zs",0);
|
|
|
+ }
|
|
|
+
|
|
|
+ public Student(String name, int age) {
|
|
|
+ //构造 第一行 先完成初始化
|
|
|
+ this(name,age,"北京");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public Student(String name, int age, String address) {
|
|
|
+ this(name,age,address,true);
|
|
|
+ }
|
|
|
+
|
|
|
+ public Student(String name, int age, String address, boolean sex) {
|
|
|
+ //this() n个构造 this() n-1
|
|
|
+ this.name = name;
|
|
|
+ this.age = age;
|
|
|
+ this.address = address;
|
|
|
+ this.sex = sex;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String toString() {
|
|
|
+ return "Student{" +
|
|
|
+ "name='" + name + '\'' +
|
|
|
+ ", age=" + age +
|
|
|
+ ", address='" + address + '\'' +
|
|
|
+ ", sex=" + sex +
|
|
|
+ '}';
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getName() {
|
|
|
+ return name;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setName(String name) {
|
|
|
+ this.name = name;
|
|
|
+ }
|
|
|
+
|
|
|
+ public int getAge() {
|
|
|
+ return age;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setAge(int age) {
|
|
|
+ this.age = age;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getAddress() {
|
|
|
+ return address;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setAddress(String address) {
|
|
|
+ this.address = address;
|
|
|
+ }
|
|
|
+
|
|
|
+ public boolean isSex() {
|
|
|
+ return sex;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setSex(boolean sex) {
|
|
|
+ this.sex = sex;
|
|
|
+ }
|
|
|
+}
|