|
|
|
|
@ -0,0 +1,37 @@
|
|
|
|
|
package com.ssm.di.xml;
|
|
|
|
|
|
|
|
|
|
// 班级实体类 DI XML版
|
|
|
|
|
public class Class {
|
|
|
|
|
private Integer classId;
|
|
|
|
|
private String className;
|
|
|
|
|
private Integer studentCount;
|
|
|
|
|
|
|
|
|
|
// 无参构造 Spring必须
|
|
|
|
|
public Class() {}
|
|
|
|
|
|
|
|
|
|
// setter方法(用于XML setter注入)
|
|
|
|
|
public Integer getClassId() { return classId; }
|
|
|
|
|
public void setClassId(Integer classId) { this.classId = classId; }
|
|
|
|
|
public String getClassName() { return className; }
|
|
|
|
|
public void setClassName(String className) { this.className = className; }
|
|
|
|
|
public Integer getStudentCount() { return studentCount; }
|
|
|
|
|
public void setStudentCount(Integer studentCount) { this.studentCount = studentCount; }
|
|
|
|
|
|
|
|
|
|
// 任务要求:重写toString方法
|
|
|
|
|
@Override
|
|
|
|
|
public String toString() {
|
|
|
|
|
return "Class{" +
|
|
|
|
|
"班级ID=" + classId +
|
|
|
|
|
", 班级名称='" + className + '\'' +
|
|
|
|
|
", 班级人数=" + studentCount +
|
|
|
|
|
'}';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 任务要求:新增printInfo输出方法
|
|
|
|
|
public void printInfo() {
|
|
|
|
|
System.out.println("===== 班级信息 =====");
|
|
|
|
|
System.out.println("班级ID:" + classId);
|
|
|
|
|
System.out.println("班级名称:" + className);
|
|
|
|
|
System.out.println("班级总人数:" + studentCount);
|
|
|
|
|
}
|
|
|
|
|
}
|