个人理财系统springboot项目开发(四)类pojo

在pojo里,放置我们定义的各种类。

习惯上,我们把属性定义成私有变量,安全。在写完所有属性之后,getter和setter并不需要我们手写,可以使用IDEA的快捷键Alt+Insert

个人理财系统springboot项目开发(四)类pojo_第1张图片

点击Getter and Setter,选择所有属性即可。

我重构了toString,这是因为调试的时候,直接输出类会输出一个地址,而我想看这个类里的全部内容,因此我Override一个toString,这样System.out.println就会输出类里的全部属性。

(Java的输出,实际上也是调用的toString函数,这一点python也是类似的。)

toString也可以用Alt+Insert,在上面的截图中可以看到,点击toString()即可。

package com.demo.pojo;

public class User {
    private Integer id;
    private String username;
    private String realname;
    private String phone;
    private String email;
    private String password;
    private String reputation;
    private Integer status;
    private String IDcard;
    private String paypwd;


    public String getIDcard() {
        return IDcard;
    }

    public void setIDcard(String IDcard) {
        this.IDcard = IDcard;
    }

    public String getPaypwd() {
        return paypwd;
    }

    public void setPaypwd(String paypwd) {
        this.paypwd = paypwd;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getPassword() {
        return password;
    }

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

    public Integer getId() {
        return id;
    }

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

    public String getUsername() {
        return username;
    }

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

    public String getRealname() {
        return realname;
    }

    public void setRealname(String realname) {
        this.realname = realname;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getEmail() {
        return email;
    }

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

    public String getReputation() {
        return reputation;
    }

    public void setReputation(String reputation) {
        this.reputation = reputation;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", username='" + username + '\'' +
                ", realname='" + realname + '\'' +
                ", phone='" + phone + '\'' +
                ", email='" + email + '\'' +
                ", password='" + password + '\'' +
                ", reputation='" + reputation + '\'' +
                ", status=" + status +
                ", IDcard='" + IDcard + '\'' +
                ", paypwd='" + paypwd + '\'' +
                '}';
    }

    public User() {
    }
}

 

你可能感兴趣的:(Java)