1 问题
本次我们要提出的问题是设计一个简易的图书管理系统可以使图书管理变得不再那么困难。
2 方法
先建造一个Book的类,包含了书名、作者、价格、类型和是否被借的属性,且设置为private类型,提供了get和set方法。还有就是用户端的实现,同样使用get和set的方法。
代码清单 1
| public class Book { private String name; private String author; private int price; private String type; private boolean isBorrowed; //是否被借 public Book(){ } public Book(String name,String author,int price,String type){ this.author = author; this.name = name; 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 int getPrice(){ 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; } public String toString(){ return "Book{" + "书名:‘" + name + ’'‘+ ",作者:’" + author + ‘'’+ ",价格:‘" + price + ",类型:’" + type +‘'’ + ",是否借出:" + isBorrowed +‘}’; } } |
3 结语
本次作业主要使用了类来完成,使用这个系统可以实现基础的借书流程,并且可以查询是谁借的,借的什么类型以及是否借出。但是这个系统提升空间还有很多,我们下来有时间继续完善此程序,类的用途很广泛,方便又简洁。在学习中,我认为自己还有很多不足,虽然书上的代码每周都认真重复敲,但还是有些不熟练,编写较长代码还是有困难,这学期课程比较有难度,因此很少有自己主动编写的程序,后面应该找时间完善自己的全部作品。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/190450.html