图书管理系统大作业

GUI管理代码

https://gitee.com/hjx127/library/tree/master/

系统功能框架图

类的设计:UML类图,应展现主要类之间的关系。

类说明:说明主要类的属性和主要方法。

Book类

  • 定义图书属性
  • 定义图书构造方法、setter和getter
public class Book {
    private String type ;
    private String id;
    private String name;
    private String date;//入馆日期
    private String state;
    private String remark;

    public Book() {
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Book(String id, String name, String type) {
        this.type = type;
        this.id = id;
        this.name = name;
    }



    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {

        this.name = name;
    }

    public String getDate() {

        return date;
    }

    public void setDate(String date)
    {
        this.date = date;
    }
}

Utils类

  • 管理员、学生登录系统
  • 打印图书信息
public static boolean loading(int type,String userName,String keyWork){
        boolean flag = false ;
        if(type == 0){
            //管理员登陆
            if(userName.equals("郑老师")){
                if(keyWork.equals("123456")){
                    flag = true;
                    System.out.println("管理员登录成功!");
                }else {
                    flag = false;
                    System.out.println("密码错误");
                }
            }else {
                flag = false;
                System.out.println("用户名错误");
            }
        }else if(type == 1){
            if(userName.equals("黄同学")){
                if(keyWork.equals("654321")){
                    flag =true;
                    System.out.println("学生登录成功!");
                }else {
                    flag = false;
                    System.out.println("密码错误");
                }
            }else {
                flag = false;
                System.out.println("用户名错误");
            }
        }
        return flag ;

    }

ManageBook类

  • 主界面系统
public static void main(String[] args) {
        ArrayList<Book> bookList = new ArrayList<>();
        Scanner sc = new Scanner(System.in);
        
        System.out.println("--------------图书馆管理系统--------------");
        while (true) 
        {
            System.out.println("请输入权限:0.管理员 1.用户 2.退出");
            int type = sc.nextInt();
            sc.nextLine();
            if(type == 2 ){
                System.out.println("退出系统!");
                System.exit(0);
            }
            System.out.println("请输入用户名:");
            String userName = sc.nextLine();
            System.out.println("请输入密码:");
            String keyWord = sc.nextLine();
            
            System.out.print("验证码为:");
            String s = Utils.createCome();
            System.out.println(s);
            
            System.out.println("请输入验证码:");
            String come = sc.nextLine();
            boolean flag =false ;
            if(come.equalsIgnoreCase(s)){
                 flag = Utils.loading(type, userName, keyWord);
            }
            else
            {
            	System.out.println("输入有误,请重新输入");
            }
            if (flag) {
                    switch (type) {
                        case 0:
                            System.out.println("------------欢迎进入管理员系统!-----------");
                            manSystem(bookList, sc);
                            break;
                        case 1:
                            System.out.println("-------------欢迎进入学生系统!-------------");
                            stuSystem(bookList, sc);
                            break;
                        default:
                            break;
                    }
                }

            }
    }

运行界面演示

管理员登陆界面

管理员查询界面

管理员添加图书界面

管理员修改图书界面

管理员删除图书界面

学生登陆界面

学生查询界面

学生借出图书界面

学生归还图书界面

特色框架

登录界面使用了验证码的操作

     //生成验证码,四位
    public static String createCome(){
        Random r = new Random();
        StringBuffer come = new StringBuffer();
        for(int i = 0 ; i < 4 ;i++){
            int op = r.nextInt(3);
            switch (op){
                case 0:
                    char come1 =(char) (r.nextInt(10) + 48);
                    come.append(come1);
                    break;
                case 1:
                    char come2 = (char) (r.nextInt(26) + 65);
                    come.append(come2);
                    break;
                case 2:
                    char come3 = (char) (r.nextInt(26) + 97);
                    come.append(come3);
                    break;
                default:
                    break;
            }

        }
        return come.toString();
    }
posted @ 2020-12-09 22:05  网络1911黄嘉欣  阅读(216)  评论(0编辑  收藏  举报
levels of contents