图书管理系统

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

功能调查

进入厦门市图书馆网页有检索功能

搜索后会出现书本信息,可以添加到书单即借阅功能

系统功能框架图

二. 类的设计

三.类的说明

Book类

记录书本的属性

class Books{
	private Integer id;
	private String name;
    private String writer;
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getWriter() {
		return writer;
	}
	public void setWriter(String writer) {
		this.writer = writer;
	}
	@Override
	public String toString() {
		return "Books [id=" + id + ", name=" + name + ", writer=" + writer + "]";
	}
	public Books(Integer id, String name, String writer) {
		super();
		this.id = id;
		this.name = name;
		this.writer = writer;
	}

BookAdded类

记录书本的借阅状态

class BooksAdded {
	private Books books;
	private int condition=0;

public BooksAdded(Books books,int condition) {
	this.books = books;
	this.condition = condition;
}

public Books getBooks() {
	return books;
}

public void setBooks(Books books) {
	this.books = books;
}

public int getCondition() {
	return condition;
}

public void setCondition(int condition) {
	this.condition = condition;
}

Library类

关于书本借阅和归还操作的类
用map类来写灵活性较强,主要是可以不用写那么多代码就可以实现功能

class Library { 
	Map<Integer,BooksAdded> al=new HashMap<Integer,BooksAdded>();
public void addBooks(Books g) {
	int condition = 1;
	int booksId = g.getId();
	if (al.containsKey(booksId)) {
		System.out.println("该书已被借阅!");
		}
		else {
			al.put(booksId, new BooksAdded(g,condition));
		}

}

public void delete(int id){ 
	al.remove(id);
}

public void View() { 
	@SuppressWarnings("unused")
	double sum = 0;
	Collection<BooksAdded> booksaddeds = al.values();
	Iterator<BooksAdded> iterator = booksaddeds.iterator();
	System.out.println("       借阅历史      ");
	System.out.println("Id\t名字\t作者\t状态");
	while(iterator.hasNext()) {
		BooksAdded booksadded = iterator.next();
		Books g = booksadded.getBooks();		
		System.out.println(g.getId()+"\t"+g.getName()+"\t"+g.getWriter()+"\t"+"借阅成功");
		}
		}
}

User类

管理用户的账号密码

class User{

private String id; private String password;

}

Administer类

管理管理员的账号密码

class Administer{

private String id; private String password;

}

四.系统的包的规划设计


五.已完成的部分初步原型

目前只完成了简单的功能,用户和管理员登录还有图形界面还没有写。

posted @ 2020-12-09 20:46  20190211飞飞  阅读(31)  评论(0编辑  收藏  举报