java----图书管理系统 (用户和管理员)

1. 描述

a> 角色

图书管理系统有两个角色对书进行操作, 分别是普通用户类和管理员类.

b> 操作

操作可划分为: 增添图书, 删除图书, 更新图书, 查找图书, 借阅图书, 归还图书, 退出系统

2. 实现

a> Book 类

package java0126;

/**
 * @author FMM
 * @version 7.0
 * @date 2021/1/26 12:37
 */
public class Book {
   
    private String name;
    private String author;
    private int price;
    private String type;
    // 表示没有被借
    private boolean isBorrowed = false;

    public Book(String name, int price, String author, String type) {
   
        this.name = name;
        this.price = price;
        this.author = author;
        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) {
   
        this.isBorrowed = borrowed;
    }

    public void bookImformation() {
   
        System.out.println(this.name + " " + this.price + " "
                + this.author + " " + this.type + " " + this.isBorrowed);
    }
}

b> BookList 类

package java0126;

import java.util.Scanner;

/**
 * @author FMM
 * @version 7.0
 * @date 2021/1/26 12:37
 */
public class BookList {
   
    private Book[] books = new Book[100] ;
    private int size;
    // 图书管理系统的关闭和开启条件
    private boolean isOpen = true;

    public BookList() {
   
        this.books[this.size++] = new Book("三国演义",100, "罗贯中","历史小说");
    }

    public void addBook(String name, int price, String author, String type) {
   
        this.books[size++] = new Book(name, price, author, type);
    }
    public Book getBook(int index) {
   
        if (!checkIndex(index)) {
   
            return null;
        }
        return this.books[index];
    }
    public void setSize(int size) {
   
        this.size = size;
    }

    public boolean isOpen() {
   
        return isOpen;
    }

    public void setOpen(boolean open) {
   
        this.isOpen = open;
    }

    public int getSize() {
   
        return this.size;
    }
    public void borrowBook(int index) {
   
        if (!checkIndex(index)) {
   
            return;
        }
        if (!this.books[index].isBorrowed()) {
   
            this.books[index].setBorrowed(true);
        }
    }
    public void displayBook() {
   
        if (
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值