Java实训GUI学生管理系统--创建实体类项目

实现步骤

步骤一:创建实体类

创建包
创建实体类

步骤二: 创建学校实体类所对应的实体表

在这里插入图片描述
可使用快捷方式Getter and Setter 和 to String()直接生成后段代码
下面展示一些 详细代码

package net.lyq.student.bean;

import java.util.Date;

public class College {
    private int id;                   //学校id
    private String name;              //学校名称
    private String president;         //校长
    private Date startTime;           //建校时间
    private String telephone;         //联系电话
    private String email;             //邮箱
    private String address;           //通信地址
    private String profile;           //学校简介
    
    //使用Getter and Setter自动生成
    
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPresident() {
        return president;
    }

    public void setPresident(String president) {
        this.president = president;
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getProfile() {
        return profile;
    }

    public void setProfile(String profile) {
        this.profile = profile;
    }
    
   //使用to String()自动生成
   
    @Override
    public String toString() {
        return "College{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", president='" + president + '\'' +
                ", startTime=" + startTime +
                ", telephone='" + telephone + '\'' +
                ", email='" + email + '\'' +
                ", address='" + address + '\'' +
                ", profile='" + profile + '\'' +
                '}';
    }
}

步骤三:创建状态类对应状态表

创建表
下面展示一些 代码详情

package net.lyq.student.bean;

public class Status {
    private int id;          //状态标识符
    private String college;  //校名
    private String version;  //软件版本
    private String aythor;   //软件作者
    private String telephone;//联系电话
    private String address;  // 通信地址
    private String email;    //电子邮箱
    
    //使用Getter and Setter自动生成
    
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getCollege() {
        return college;
    }

    public void setCollege(String college) {
        this.college = college;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public String getAythor() {
        return aythor;
    }

    public void setAythor(String aythor) {
        this.aythor = aythor;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }
    
   //使用to String()自动生成
   
    @Override
    public String toString() {
        return "Status{" +
                "id=" + id +
                ", college='" + college + '\'' +
                ", version='" + version + '\'' +
                ", aythor='" + aythor + '\'' +
                ", telephone='" + telephone + '\'' +
                ", address='" + address + '\'' +
                ", email='" + email + '\'' +
                '}';
    }
}

步骤四:创建学生实体类对应学生表

学生实体类
下面展示一些 内联代码片

package net.lyq.student.bean;

public class Student {
    private String id;              //学号
    private String name;            //姓名
    private String sex;             //性别
    private int age;                //年龄
    private String department;      //系部
    private String clazz;           //班级
    private String telephone;       //联系电话
    
    //使用Getter and Setter自动生成
 
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getDepartment() {
        return department;
    }

    public void setDepartment(String department) {
        this.department = department;
    }

    public String getClazz() {
        return clazz;
    }

    public void setClazz(String clazz) {
        this.clazz = clazz;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }
    
    //使用to String()自动生成
   
    @Override
    public String toString() {
        return "Student{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", sex='" + sex + '\'' +
                ", age=" + age +
                ", department='" + department + '\'' +
                ", clazz='" + clazz + '\'' +
                ", telephone='" + telephone + '\'' +
                '}';
    }
}

步骤五:创建用户实体类对应的用户表

用户表

下面展示一些 内联代码片

package net.lyq.student.bean;

import java.util.Date;

public class User {
    private int id;                 //用户标识符
    private String username;        //用户名
    private String password;        //密码
    private String telephone;       //联系电话
    private Date registerTime;      //注册时间
    
   //使用Getter and Setter自动生成

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    public Date getRegisterTime() {
        return registerTime;
    }

    public void setRegisterTime(Date registerTime) {
        this.registerTime = registerTime;
    } 
    
    //使用to String()自动生成
   
    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", telephone='" + telephone + '\'' +
                ", registerTime=" + registerTime +
                '}';
    }
}

猜你喜欢

转载自blog.csdn.net/weixin_46705517/article/details/107076672