[Java]图书管理系统

系统需求

1.登录

2.身份选择:管理员和用户

3.管理员功能:查找图书、新增图书、删除图书、显示图书、退出系统。

4.用户功能:查找图书、借阅图书、归还图书、退出系统。

设计:

分别设计三个包:book包、operation包和user包。book包用来存储原始书籍,operation包用来实现各种功能,user包来区别管理员和用户的功能。最后用Main的class来连接实现。

Book

package book;

public class Book {
    private String name;
    private String author;
    private int price;
    private String type;//书的类型
    private boolean isBorrowed;//默认是false


    public Book(String name, String author, int price, String type) {
        this.name = name;
        this.author = author;
        this.price = price;
        this.type = type;
    }

    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 getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public boolean isBorrowed() {
        return isBorrowed;
    }

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

    @Override
    public String toString() {
        return "Book{" +
                "name='" + name + '\'' +
                ", author='" + author + '\'' +
                ", price=" + price +
                ", type='" + type + '\'' +
                (isBorrowed == true ? "  已借出" : "  未借出") +
                '}';
    }
}

BookList

package book;

public class BookList {

    private Book[] bookList = new Book[10];
    private int usedSize;//当前书架上有几本书

    public BookList(){
        this.bookList[0] = new Book("三国演义","罗贯中",18,"小说");
        this.bookList[1] = new Book("西游记","吴承恩",20,"小说");
        this.bookList[2] = new Book("红楼梦","曹雪芹",45,"小说");
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值