图书管理系统—JavaSE实现

图书管理系统

一、项目框架

1、在idea中新建一个项目取名为:BookManagement。
2、在项目的src目录下按照以下结构创建对应的 包 和.java文件。
          在这里插入图片描述

二、图书模块代码

1、Book

package book;

/**
 * Remarks: book类
 * Author:panlai
 * :Date:2021/4/14
 */
public class Book {
   
    private String name;
    private String author;
    private  int price;
    private String type;
    private boolean isBoeeowed;

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

    public void setBoeeowed(boolean boeeowed) {
   
        isBoeeowed = boeeowed;
    }

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

2、BookList

package book;

/**
 * Remarks: 图书列表
 * Author:panlai
 * :Date:2021/4/14
 */
public class BookList {
   
    private Book[] books = new Book[100];
    private  int usedSize = 0;

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

    //可以吧所有的操作都写在这个类当中,因为每个类都是操作books的,但是为了用接口,就不这样做了

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

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


    public 
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值