<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                ## 1、編寫并測試 Subject 類 ``` public class Subject { private String name; // 學科名稱 private String code; // 學科編號 private int year; // 學制年限 public Subject() {} public Subject(String name, String code, int age) { this.setName(name); this.setCode(code); this.setAge(age); } public String getName() { return this.name; } public void setName(String name) { this.name = name; } public String getCode() { return this.code; } public void setCode(String code) { this.code = code; } public int getYear() { return this.year; } public void setYear(int year) { this.year = year; } public void info() { System.out.println("專業信息如下:"); System.out.println("專業名稱:" + this.getName()); System.out.println("專業編號:" + this.getCode()); System.out.println("學制年限:" + this.getYear() + "年"); } } ``` ## 2、編寫并測試 Student 類 ``` public class Student { private String code; // 學號 private String name; // 姓名 private String gender; // 性別 private int age; // 年齡 public Student() {} public Student(String code, String name, String gender, int age) { this.setCode(code); this.setName(name); this.setGender(gender); this.setAge(age); } public String getCode() { return this.code; } public void setCode(String code) { this.code = code; } public String getName() { return this.name; } public void setName(String name) { this.name = name; } public String getGender() { return this.gender; } public void setGender(String gender) { this.gender = gender; } public int getAge() { return this.age; } public void setAge(int age) { this.age = age; } public void introduction() { System.out.println("學生信息如下:"); System.out.println("姓名:" + this.getName()); System.out.println("學號:" + this.getCode()); System.out.println("性別:" + this.getGender()); System.out.println("年齡:" + this.getAge()); } } ``` ## 3、通過方法實現學生與專業關聯 * 方式一 ``` public class Student { public void introduction(String name, int year) { System.out.println("學生信息如下:"); System.out.println("姓名:" + this.getName()); System.out.println("學號:" + this.getCode()); System.out.println("性別:" + this.getGender()); System.out.println("年齡:" + this.getAge()); System.out.println("所報專業名稱:" + name); System.out.println("學制年限:" + year + "年"); } } ``` * 方式二 ``` public class Student { public void introduction(Subject subject) { System.out.println("學生信息如下:"); System.out.println("姓名:" + this.getName()); System.out.println("學號:" + this.getCode()); System.out.println("性別:" + this.getGender()); System.out.println("年齡:" + this.getAge()); System.out.println(subject); } } ``` * 方式三 ``` public class Student { // ... private Subject subject; public Subject getSubject() { return subject; } public void setSubject(Subject subject) { this.subject = subject; } public void introduction() { System.out.println("學生信息如下:"); System.out.println("姓名:" + this.getName()); System.out.println("學號:" + this.getCode()); System.out.println("性別:" + this.getGender()); System.out.println("年齡:" + this.getAge()); System.out.println(this.getSubject()); } } ``` ## 4、完成學生信息存儲 ``` public class Subject { private Student[] students = new Student[200]; // 報名選修的學生信息 private int count; // 報名選修的學生個數 public Subject(String name, String code, int age, Student[] students) { this.setName(name); this.setCode(code); this.setAge(age); this.setStudents(students); } public Student[] getStudents() { return this.students; } public void setStudents(Student[] students) { this.students = students; } public int getCount() { return this.count; } public void setCount(int count) { this.count = count; } /** * 專業添加學生的同時需要給學生設置專業屬性 */ public void addStudent(Student student) { for (int i = 0; i < this.getStudents().length; i++) { if (this.getStudents()[i] == null) { student.setSubject(this); this.getStudents()[i] = student; this.setCount(i + 1); break; } } } } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看