Bootstrap

Java简易图书管理系统

实体类beans

book

package com.hwq.beans;


//实体类
public class Book {
    private int id;
    private String name;
    private String author;
    private int number;
    private boolean isBorrowed;//是否被借出

    public Book() {
    }

    public Book(int id, String name, String author, int number) {
        this.id = id;
        this.name = name;
        this.author = author;
        this.number = number;

    }



    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 getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public int getNumber() {
        return number;
    }

    public void setNumber(int number) {
        this.number = number;
    }

    public boolean isBorrowed() {
        return isBorrowed;
    }

    public void setBorrowed(boolean borrowed) {
        isBorrowed = borrowed;
    }

    @Override
    public String toString() {
        return "Book{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", author='" + author + '\'' +
                ", number=" + number +
                ", isBorrowed=" + isBorrowed +
                '}';
    }
}

BookSlip

借书还书

package com.hwq.beans;

import java.util.Date;

public class BookSlip {
    private int id;
    private int userid;
    private int bookid;
    private Date jdate;
    private Date hdate;

    public BookSlip() {
    }

    public BookSlip(int id, int userid, int bookid, Date jdate, Date hdate) {
        this.id = id;
        this.userid = userid;
        this.bookid = bookid;
        this.jdate = jdate;
        this.hdate = hdate;
    }

    public int getId() {
        return id;
    }

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

    public int getUserid() {
        return userid;
    }

    public void setUserid(int userid) {
        this.userid = userid;
    }

    public int getBookid() {
        return bookid;
    }

    public void setBookid(int bookid) {
        this.bookid = bookid;
    }

    public Date getJdate() {
        return jdate;
    }

    public void setJdate(Date jdate) {
        this.jdate = jdate;
    }

    public Date getHdate() {
        return hdate;
    }

    public void setHdate(Date hdate) {
        this.hdate = hdate;
    }

    @Override
    public String toString() {
        return "BookSlip{" +
                "id=" + id +
                ", userid=" + userid +
                ", bookid=" + bookid +
                ", jdate=" + jdate +
                ", hdate=" + hdate +
                '}';
    }
}

User

package com.hwq.beans;

public class User {
    private int id;
    private String name;

    private String sex;
    private String pwd;
    private int member;
    public User() {
    }

    public User(int id, String name, int member, String sex, String pwd) {
        this.id = id;
        this.name = name;
        this.member = member;
        this.sex = sex;
        this.pwd = pwd;
    }

    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 int getMember() {
        return member;
    }

    public void setMember(int member) {
        this.member = member;
    }

    public String getSex() {
        return sex;
    }

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

    public String getPwd() {
        return pwd;
    }

    public void setPwd(String pwd) {
        this.pwd = pwd;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", sex='" + sex + '\'' +
                ", pwd='" + pwd + '\'' +
                ", member=" + member +
                '}';
    }
}

控制层controller

BookController

package com.hwq.controller;


import com.hwq.beans.Book;
import com.hwq.beans.BookSlip;
import com.hwq.beans.User;
import com.hwq.service.BookService;
import com.hwq.service.impl.BookServiceimpl;

//import com.hwq.service.impl.BookSlipSerbiceimpl;

import java.util.List;
import java.util.Scanner;

//控制层
public class BookController {
        Scanner sc=new Scanner(System.in);
        BookService bookService=new BookServiceimpl();
//        BookSlipService bookSlipService=new BookSlipSerbiceimpl();

        //主方法
    public void show(User user){
        System.out.println("【1】查看图书,【2】添加图书,【3】修改图书,【4]删除图书,【5】返回上一层");
        System.out.println("请输入你想要的操作:");
        int a=sc.nextInt();
        if (a==1){
            showbook();
            show(null);
        }else if (a==2){
            addbooks();
            show(null);
        }else if (a==3){
            updatebooks();
            show(null);
        }else if (a==4){
            delbooks();
            show(null);
        }else if (a==5){
            new UserController().register(user);
        }else {
            System.out.println("输入有误!请重新输入");
            show(null);
        }
    }

    public void m
;