Java图书管理系统

(非正式管理系统,任务导向型。)
#下面是该系统的说明及相关文档:
Introduction
This will be done in the form of a library system that allows users to borrow various items that the library holds. You will be required to create an inheritance structure to contain all the different types of items the library might hold. In this case there are five different types of items Books, Magazines, Blurays, DVDs and MusicCDs.

  • You are required to create a library class that manages this system allowing an item to added or removed in addition to allowing a person to borrow an item and return it.
  • This program is supplied with an incomplete testing program, you must complete the test driver to ensure the completeness of your library system.
  • You are also required to generate the rest of the classes to describe the items held in your library using a suitable inheritance model in your program.

Description of the System
There are a number of different types of items in the library. There are Books, Magazines, MusicCDs and Movies.
Movies in turn can be DVDs or Blurays. You will need to implement these items as an inheritance structure with
appropriate setter and getter methods in addition to appropriate access permissions. As a starting point:

  • All items contain an id (String), a name (String), loaned (boolean), borrower (Person), and a cost (double).
  • All Books will have an author (String)
  • All Magazines will have distributionCity (String) and a
    magazineFrequency (Frequency) based on an enumerated
    type which has day, week monthly, quarterly and yearly.
  • All Movies will have an genre (Genre) based on an enumerated type Genre which has scifi, action, drama and romance
  • All DVDs will have a region (int)
  • All Blurays will have region (char) All MusicCD’s will have composer (String) and an artist (String)

In addition to the Library class described, there are also a few other classes needed for this assignment:

  • A Library contains the list of items (ArrayList of Items) currently held by the library
  • A Person has a name (String) and an address (String). Library items can be borrowed by a person.
  • A TestDriver (supplied with incomplete tests) that will test your program.
  • DuplicateItemException (Supplied). This exception object is Thrown when a duplicate item is inserted into the Library.
  • ItemNotFoundException (Supplied). This exception object Thrown when an item is not found in the list
  • In summary you should have 12 classes including the TestDriver.

Error Handling
To complete the assignment effectively there are some rules regarding exceptions:

  • In the event that an input is incorrect an Exception should be thrown. Eg invalid region for a bluray or dvd.
  • If you try to find an item that doesn’t exist you should throw an ItemNotFoundException
  • If you try to insert an item that already exists you should get a DuplicateItemException
  • In the event of any other error situations you should throw an exception.

Testing
You are to write a series of tests to make sure your program is uncrashable. You should do this in a test document (a text document included in your project called test.txt). That document should list each method in library with the tests that you consider need to be performed. You should then code your test conditions in the testDriver class. When you run your program you should have the following form of output.
Testing addItem***
-Test add an item and see if it is in the list-
Expected Found
Got Found
Success
-Test adding a new item then retrieving an item that doesn’t exist-
Expected Not Found
Got Not Found
Success
**
You should have one test for every scenario you can think of. In the first example above you would call the addItem with a parameter of a new item then would try finding the item. If an item is returned print out found and declare the test a success.
I will give you a basic test driver that you can expand for the assignment.

Restrictions
There are a number of rules you must follow when addressing the requirements for this assignment.

  • You must use inheritance.
  • You must have all the named classes (Library, Person, TestDriver and the two Exception objects).
  • Your Library class must have the methods EXACTLY as specified. I‘ll say this one again Your Library class must have the methods EXACTLY as specified.
  • If you don’t it wont compile when I dump my testing class in the folder and you will fail the assignment.

附上原说明文档:该项目的说明文件及基础代码
文件中含以下内容,其中HTML为说明文档,其他为基础代码
大致意思就是完成Library类及各种Item项目的类并通过测试!
贴代码太麻烦,我就直接上完成好的项目文档吧!
需要的自行下载:该项目完成后的项目压缩包
里面的内容如下图:

这里附上Library类的相关代码:(其他请下载项目压缩包)

import java.util.ArrayList;/*** Library类* @author* @version 1.0*/
public class Library {  /*** itemList contains the List of all items in the library.*/private ArrayList itemList = new ArrayList();/*** count of all the items in the library.*/private int count=0;/*** Changes the status of the named item to borrowed * and adds the Person to the borrowed * @param id The ID of the item to be borrowed* @param newPerson The borrower of the item* @throws ItemNotFoundException thrown if the id is not found.*/public void loanItem(String id, Person newPerson) throws ItemNotFoundException {//TODO:  Finish this methodItem find_one=findItem(id);find_one.setLoaned(true);Person copy=new Person(newPerson);find_one.setBorrower(copy);}/*** Changes the status of the named item to not borrowed and removes the user from the item.* The borrower (person) is returned to the caller* @param id The id of the item* @return The person who borrowed the item* @throws ItemNotFoundException thrown if the id is not found.*/public Person returnItem(String id) throws ItemNotFoundException {//TODO:  Finish this methodItem find_one=findItem(id);Person borrower=find_one.getBorrower();find_one.setLoaned(false);find_one.setBorrower(null);//return null so the code still compiles.  You will need to change itreturn borrower;}/*** Find the item by the given ID and return that Item* @param id The item to be returned* @return The item searched for.* @throws ItemNotFoundException thrown if the id is not found.*/public Item findItem(String id) throws ItemNotFoundException {//TODO:  Finish this methodfor(int i=0;i<itemList.size();i++){if(((Item)itemList.get(i)).getId().equals(id)){return (Item)itemList.get(i);}}throw new ItemNotFoundException("Cann't find this item!");//return null so the code still compiles.  You will need to change it}/*** Gets the borrower of an item.  If the item is not found throw ItemNotFoundException.* * @param id the id of the item* @return the borrower of the item.  returns null if the item exists but is not borrowed.* @throws ItemNotFoundException thrown if the id is not found*/public Person getBorrower(String id) throws ItemNotFoundException {//TODO:  Finish this method//return null so the code still compiles.  You will need to change itreturn findItem(id).getBorrower();}/*** Look up the name of the library item based on the ID given.* @param id The id of item searched for. * @return The name of the item blank if not found.*/public String nameForID(String id) {//TODO:  Finish this methodString find_name="";try{find_name=findItem(id).getName();}catch(ItemNotFoundException e){System.out.print("Item not find!");}return find_name;//return null so the code still compiles.  You will need to change it}/*** Returns the id of the library item based on the name given.* * @param name the name of the item* @return the id of the item blank if not found.*/public String IDForName(String name) {//TODO:  Finish this methodString find_id="";try{find_id=findItem(name).getId();}catch(ItemNotFoundException e){System.out.print("Item not find!");}return find_id;//return null so the code still compiles.  You will need to change it}/*** Add a new item to the list of library items.* * @param newItem The new item to be added to the list.* @throws DuplicateItemException thrown if the item is already in the list.*/public void addItem(Item newItem) throws DuplicateItemException{//TODO:  Finish this methodItem item=null;//遍历集合for (int i = 0; i < itemList.size(); i++){item =(Item)itemList.get(i);if(newItem.id.equals(item.id)){throw new DuplicateItemException("You are adding Duplicate item");}}Item copy_one=new Item();copy_one=newItem;itemList.add(copy_one);count++;}/*** Return the number of Items that are either Blurays or DVDs* @return the number of blurays and DVDs*/public int countMovies() {//TODO:  Finish this methodint movieCount=0;for(int i=0;i<itemList.size();i++){if(((Item)itemList.get(i) )instanceof Movies){movieCount++;}}//return -99999 so the code still compiles.  You will need to change itreturn movieCount;}/*** Convert the entire library to a string.  This should call the appropriate toString methods of each item in the ArrayList.* Should be in the format<pre>
Magazine [magazineFrequency=day, distributionCity=San Andreas]Item [id=ID000, name=Vanity Not So Faire, loaned=false, borrower=null, cost=5.95]
Magazine [magazineFrequency=day, distributionCity=San Andreas]Item [id=ID001, name=Click, loaned=false, borrower=null, cost=5.95]
Magazine [magazineFrequency=day, distributionCity=San Andreas]Item [id=ID002, name=Renovate, loaned=false, borrower=null, cost=5.95]
太多,就删了,都是各项目的toString,格式跟上面一样,各Item数据都是在TestDriver中添加的!</pre>*/public String toString() {//TODO:  Finish this methodString a="";for(int i=0;i<itemList.size();i++){a=a+((Item)itemList.get(i)).toString()+"\n";}return a;}/*** Checks if a specific library item is borrowed.* @param id The id of the item that is to be checked.* @return the status of the item whether it is borrowed or not.* @throws ItemNotFoundException thrown if the id is not found.*/public boolean isBorrowed(String id) throws ItemNotFoundException {return findItem(id).isLoaned();} /*** Return the total number of items out on loan.* @return The number representing the number of items currently on loan*/public int countBorrowed() {//TODO:  Finish this methodint borrowedCount=0;for(int i=0;i<itemList.size();i++){if(((Item)itemList.get(i)).isLoaned()){borrowedCount++;}}//return -99999 so the code still compiles.  You will need to change itreturn borrowedCount;}/*** The percentage of the number of items that are out on loan.  Expressed as a percentage of borrowed to total number of items.* @return the percentage borrowed.*/public double percentageBorrowed() {//TODO:  Finish this methoddouble a;a=(( (double)countBorrowed()/(double) itemList.size())*100);return a;}
}

Java图书管理系统(非正式系统任务导向型,内含完整项目代码),编辑Library类并完成TestDriver,南澳大学计算机大作业。相关推荐

  1. Java图书管理系统练习程序(四)

    2019独角兽企业重金招聘Python工程师标准>>> Java图书管理系统练习程序(四) 本部分主要介绍List的基本操作与Java中泛型的使用. 一.Java中泛型的使用 泛型, ...

  2. java图书管理系统技术难度_Java图书管理系统练习程序(一)

    Java图书管理系统练习程序 第一部分 该部分主要实现命令行方式的界面与无数据库访问的练习,通过本练习.主要掌握Java的基础知识与面向对象程序设计思想.面向接口编程技术的知识与运用. 一.练习程序功 ...

  3. 视频教程-手把手实现Java图书管理系统(附源码)-Java

    手把手实现Java图书管理系统(附源码) 南京大学软件工程硕士,曾就职于擎天科技.中软国际.华为等上市公司,擅长Java开发.Web前端.Python爬虫.大数据等领域技术. 全栈工程师,从事软件开发 ...

  4. [附源码]计算机毕业设计JAVA图书管理系统

    [附源码]计算机毕业设计JAVA图书管理系统 项目运行 环境配置: Jdk1.8 + Tomcat7.0 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(Intell ...

  5. java图书管理系统源码

    java图书管理系统源码 系统主要功能 读者:登录注册,借阅还书,查询书籍,查看当前借阅信息以及历史借阅信息,查看.查询读者借阅榜以及借阅书籍借阅榜,问题反馈以及查询反馈结果等功能. 管理员:对图书. ...

  6. springboott整合mybatis-plus和sharding-jdbc实现分库分表和读写分离(含完整项目代码)

    springboott整合mybatis-plus和sharding-jdbc实现分库分表和读写分离(含完整项目代码) 一.整合sharding-jdbc 关于springboot整合sharding ...

  7. 如何实现抖音狗头,人工智能,附完整项目代码

    详细见 人工智能python+dlib+opencv技术10分钟实现抖音人脸变狗头详细图文教程和完整项目代码 https://blog.csdn.net/wyx100/article/details/ ...

  8. Spark Core项目实战(1) | 准备数据与计算Top10 热门品类(附完整项目代码及注释)

      大家好,我是不温卜火,是一名计算机学院大数据专业大二的学生,昵称来源于成语-不温不火,本意是希望自己性情温和.作为一名互联网行业的小白,博主写博客一方面是为了记录自己的学习过程,另一方面是总结自己 ...

  9. 基于JSP(java)图书管理系统的设计和实现(含源文件)

    获取项目源文件,联系Q:1225467431,可指导毕设,课设 摘 要 伴随着互联网的蓬勃发展,人们已经不再满足于信息的浏览和发布,而是渴望着能够充分享受网络所带来的更加多的便利.掌握计算机知识和应用 ...

  10. 我的第一个项目----Java图书管理系统

    项目参考自:http://www.java1234.com/a/yuanchuang/swing2/ 项目视频及代码下载地址:链接:http://pan.baidu.com/s/1pLpQw2J 密码 ...

最新文章

  1. 注释的编写方式:写明白来龙去脉提高代码产出率
  2. android 格式化代码
  3. java流程控制both_java web面试题
  4. go语言 rune切片
  5. sa密码不满足强密码要求_恢复丢失的SA密码
  6. Druid 在有赞的实践
  7. Javascript设置对象的ReadOnly属性
  8. 使用redis解决tomcat6在nginx负载下多节点共享session问题
  9. 如何用思维导图快速理解PMBOK-PMP第六版教材
  10. OBS推流 rtmp服务器(docker) python opencv拉流
  11. 李彦宏创业12年解读:企业家精神改变工程师命运
  12. 关于STM32F407ZGT6的一些知识小结及串口1程序
  13. 【友情链接NO.0000?】大佬们的博客(°ー°〃)
  14. Java实现发邮件功能
  15. 前景背景样本不均衡解决方案:Focal Loss,GHM与PISA(附python实现代码)
  16. android平板接口,初学者必读 细品平板接口的百般滋味
  17. 183套免费简历模板,助大伙找个好工作
  18. go iris 源码思路分析
  19. 《最高人民法院最高人民检察院关于办理非法利用信息网络、帮助信息网络犯罪活动等刑事案件适用法律若干问题的解释》
  20. DFS BFS简单理解

热门文章

  1. xml转PDF(xmlxslt-」fo-」pdf)_完整项目_CodingPark编程公园
  2. foxpro导入 mysql_无法导入、导出或链接到 FoxPro 数据库 | Microsoft Docs
  3. 调用支付宝网页支付被浏览器拦截
  4. 浅谈计算机网络发展方向,浅谈计算机网络的发展方向
  5. Phoenix 升級报Cluster is being concurrently upgraded from 4.9.x to 4.13.x 错误
  6. android 钛备份,钛备份使用教程
  7. iOS Facebook pop动画进阶
  8. 充电器pps功能是什么_科普:PPS充电器是什么?为何不兼容笔电?
  9. 小程序授权登录注册自有账户体系
  10. 计算机桌面文件能单独设密码吗,告诉你怎么给文件夹设置密码