• 面向对象设计大作业


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

    类的设计

    类说明

    Test类登陆系统,进行对应测试
    User类为Admin类和NormalUser类的父类,进行对应的函数调用
    NormalUser类为用户目录及数组存储对应相应输入的函数调用
    Admin类为管理员目录及数组存储对应相应输入的函数调用
    Book类创建书籍属性
    BookList类bookList存储图书馆书籍信息,borrowList存储借书单信息
    Search类实现关键字查询
    Add类增加图书馆书籍
    Delete类删除图书馆书籍
    Borrow类实现借阅并将借阅书籍加入借书单
    Return类实现归还书籍
    Print类打印图书馆书籍信息
    Print2类打印借书单信息
    Exit类退出系统

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

    关键代码

    Search类实现模糊查找

    public class Search<Employee> implements IO{
    	public void work(BookList bookList) {
    		Scanner sc = new Scanner(System.in);
    		int flag=0;
    		System.out.println("请输入需要查找的书籍的相关信息:");
    		String information = sc.next();
    		Pattern pattern = Pattern.compile(information);
    		   for(int i=0; i < bookList.getSize();i++){
    		      Matcher matcher = pattern.matcher(bookList.getBook(i).getName());
    		      Matcher matcher1 = pattern.matcher(bookList.getBook(i).getId());
    		      Matcher matcher2 = pattern.matcher(bookList.getBook(i).getAuthor());
    		      if(matcher.find()||matcher1.find()||matcher2.find()){
    		         System.out.println(bookList.getBook(i));
    		         flag=1;
    		      }
    		   }
    		   if(flag==0) {
    			   System.out.println("查询失败");
    		   }
    	}
    }
    

    具体功能基本实现,gitee地址:https://gitee.com/misty-rain-xiaoyu/java-code/tree/master/图书管理系统

  • 相关阅读:
    【汇编程序】出地址为BUF的5个字符数组的内容之和
    Ugly Number
    Best Time to Buy and Sell Stock IV****
    Best Time to Buy and Sell Stock III
    Best Time to Buy and Sell Stock
    Best Time to Buy and Sell Stock II
    House Robber II
    Contain Duplicate III*******
    Contain Duplicate II
    Contain Duplicate
  • 原文地址:https://www.cnblogs.com/2b-or-not-2b-/p/14094651.html
Copyright © 2020-2023  润新知