JavaSE:图书管理系统

1.图书管理系统展示

这是最终效果展示,可以根据输入身份的不同,从而进入不同的身份内容去,不同的身份内容有不同的功能
在这里插入图片描述
在这里插入图片描述

2.图书管理系统实现

2.1 book包

2.1.1 Book类

书类中封装度很高,一般不露出任何一点成员变量

package book;

public class Book {
   
    private String name;
    private String author;
    private double price;
    private String type;
    private boolean isBorrowed;

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

    public Book(String name, String author, double 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 double getPrice() {
   
        return price;
    }

    public void setPrice(double 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;
    }
}

2.1.1 BookList

BookList是一个书架,存储书,我们默认是10本书,并且给定三本默认的图书

package book;

public class BookList {
   
    Book[] books = new Book[10];

    private int usedSize;

    public BookList() {
   
        books[0] = new Book("三国演义","罗贯中",19,"小说");
        books[1] = new Book("西游记","吴承恩",29,"小说");
        books[2] = new Book("红楼梦","曹雪芹",9,"小说");
        usedSize = 3;
    }

    public void setBooks(
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值