Java实现简单的图书管理系统

简单的图书管理系统可以实现以下要求:
1,以不同的角色进行登录(管理员,普通用户);
2,管理员可以实现查找图书,上架图书,删除图书,显示所有图书等功能。
在这里插入图片描述
3,普通用户登录后实现查书书,借书,还书功能。
在这里插入图片描述

1:项目分布

2:代码实现

1.Book类

package com.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 ? "已经借出":"未借出")+
                //", isBorrowed=" + isBorrowed +
                '}';
    }
}

2.BookList类

package com.book;

public class BookList {
   
    //Book[] books = new Book[10];
    private Book[] books = new Book[10];
    private int usedSize;

    public BookList() {
   
        books[0] = new Book("三国演义","罗贯中",56,"小说");
        books[1] = new Book("西游记","吴承恩",76,"小说");
        books[2] = new Book("水浒传","施耐庵",96,"小说");
        this.usedSize = 3;
    }

    public void setBooks(int pos,Book book) {
   
        books[pos] = book;
    }

    public Book getBook(int pos) {
   
        return books[pos];
    }

    public int getUsedSize() {
   
        return usedSize;
    }

    public void setUsedSize(int usedSize) {
   
        this.usedSize = usedSize
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值