JAVA实现图书管理系统

本文通过使用JAVA编程,结合类、抽象类、封装、继承、多态和接口,设计了一个包含登录、书籍管理(增加、删除、查询)及用户借还书功能的图书管理系统。系统具备良好的扩展性,并提供了简易的交互界面。
摘要由CSDN通过智能技术生成

利用:类,抽象类,封装,继承,多态,接口等进行的一个简单的代码练习。
要实现的功能:
1、简单的登录
2、管理端
整理书籍(该功能为可扩展功能)
查阅书籍
增加书籍
删除书籍
打印书籍列表
退出
3、用户端
查询书籍
借阅书籍
归还书籍
退出
界面:
在这里插入图片描述在这里插入图片描述
包和类的创建:
在这里插入图片描述

package book;

public class Book {
   // 创建了一个Book类
    private  String name;   //Book的属性
    private  String author;
    private  double price;
    private  String type;
    private  String  borrowed="未借出";

    public Book(String name, String author, double price, String type) {
   //constructor  构造方法
        this.name = name;
        this.author = author;
        this.price = price;
        this.type = type;
    }
//set()是给属性赋值的,get()是取得属性值的
//被设置和存取的属性一般是私有
//主要是起到封装的作用,不允许直接对属性操作
//set()和get()不一定同时存在,看程序需求
    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 String getBorrowed() {
        return borrowed;
    }

    public void setBorrowed(String borrowed) {
        this.;
    }*/

    public String getBorrowed() {
   
        return borrowed;
    }

    public void setBorrowed(String borrowed) {
   
        this.borrowed = borrowed;
    }

    @Override
    public String toString() {
   
        //如果不重写toString方法 那么打印的是Object 类的 toString 方法返回一个字符串
        // 该字符串由类名(对象是该类的一个实例)、at 标记符“@”和此对象哈希码的无符号十六进制表示组成。
        //重写前打印的是对象的地址值,重写后打印的是对象的属性
        return "Book{" +
                "name='" + name + '\'' +
                ", author='" + author + '\'' +
                ", price=" + price +
                ", type='" + type + '\'' +
                ", isBorrowed=" + borrowed +
                '}';
    }
}
package book;

public class BookList {
   
    private Book[] books = new Book[100];
    private int usedSize = 0;

    public BookList() {
   
        books[0] = new Book("西游记", "吴承恩", 12.5, "文学");
        books[1] = new Book("水浒传", "施耐庵", 24.0, "文学");
        ;
        books[2] = new Book("三国演义", "罗贯中", 30.5, "文学");
        usedSize = 3;
    }

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

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

    public int getUsedSize() {
   
        return usedSize
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值