面向对象设计大作业第二阶段

1.功能调查与系统功能框架图

功能调查:

图书馆管理系统中用户有有普通用户和管理员用户,分别执行不同的操作。
普通用户登陆时只有查书,借书,还书的功能。
管理员用户登录时有查书,增加书籍,删除书籍的功能。

系统功能框架图

2.类的设计(UML类图)

3.类说明

ui.Login类
整个程序的入口,包含了main函数,以及界面的设计,登入信息的存储等
model.Book类
包含了书名、作者、价格、编号等主要属性,自动生成setter/getter/toString等方法
dao.iml.LibraryBooksFilelml.itemBook类
属性包含Book书名, allNumber图书馆内全部的书,inventory馆内库存数量,borrowed已被借走的数量。
重要方法包含:
public void borrow(int number)借书操作
public void returned(int number)还书操作
public void increase(int number)新增图书
设计itemBook为图书馆内一类书的实现,包含书名与书的数量等信息,包含对这一类的数量的修改等功能。
dao.iml.LibraryBooksFilelml类
属性包含List<itemBook> allBook来存储图书信息,String pathname用来存放路径名,涉及到文件读取
重要方法包含:
public boolean borrowBook(Book book, int number)借书功能
public boolean returnBook(Book book, int number)还书功能
public boolean addBook(Book book, int number)增加书籍功能
public boolean removeBook(Book book)删除书籍功能
public void ResetFile()重置更新文件
public LibraryBooksDaoFilelml()初始化图书馆,对文件分行进行读取,将数据初始化入图书馆

public LibraryBooksDaoFilelml() {
	allBook = new ArrayList<itemBook>();
	File file = new File(pathname);
	try {
		Reader rd = new FileReader(file);
		BufferedReader br = new BufferedReader(rd);
		String str = null;
		while((str = br.readLine()) != null) {
			String[] s = str.split(" ");
			Book book = new Book(s[0], s[1], s[2], Double.parseDouble(s[3]));
			int number = Integer.parseInt(s[4]);
			int inventory = Integer.parseInt(s[5]);
			int borrowed = Integer.parseInt(s[6]);
			itemBook itembook = new itemBook(book, number);
			itembook.setInventory(inventory);
			itembook.setBorrowed(borrowed);
			allBook.add(itembook);
		}
		br.close();
		rd.close();
	} catch (FileNotFoundException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}

4.系统的包(package)的规划设计

5.特色(可选):

1、使用DAO模式

仅使用一个dao接口封装部分代码操作,方便以后修改功能或使用数据库的实现。
2、是否进行数据持久化(数据存储)?准备使用什么方案?
实现数据持久化,将每一类书的数据实现读写操作,存储在txt文本之中
3、部分功能演示
普通用户登入界面

展示图书

借书操作

管理员增加图书

posted @ 2020-12-09 14:18  宋思坡201921123103  阅读(106)  评论(0编辑  收藏  举报