第一次写博客,关于图书馆管理系统的代码。

一个学生大一写的课程设计代码,23333!!!
望各位前辈能评价下。。。

import java.awt.print.Book;
import java.util.*;
import java.text.SimpleDateFormat;
import java.io.*;
public class user{
    public static void main(String args[]){
        int b=0,c=100;
        book Book[]=new book[5];
        Book[0]=new book("LU","TOM",101);
        Book[1]=new book("LUN","TOM",102);
        Book[2]=new book("L1","TOM",103);
        Book[3]=new book("U2","TOM",104);
        Book[4]=new book("LOL","TOM",105);
        find Find=new find(Book);
        Scanner d=new Scanner(System.in);
        System.out.println("欢迎进入智慧图书馆系统v0.9版本\n\n");
        while(true){
        System.out.println("*********************");
        System.out.println("1.显示所有书籍信息");
        System.out.println("2.查找图书");
        System.out.println("3.借阅图书");
        System.out.println("4.查询被借图书信息");
        System.out.println("5.还书");
        System.out.println("6.管理员登陆数据操作修改");
        System.out.println("7.备份所有图书信息");
        System.out.println("8.查询应当归还的书籍");
        System.out.println("0.退出系统按");
        System.out.println("*********************\n");
        b=d.nextInt(); 
        if(b==1){
            for(book A:Book){
                System.out.println(Find.A1(A));
            }
            System.out.println("\n");
        }
        if(b==2){
            System.out.println("1.通过书名查询");
            System.out.println("2.通过书名查询");
            System.out.println("3.通过isbn码查找\n");
            c=d.nextInt();
            d.nextLine();
            if(c==1){
                System.out.println("请输入书名:");
                Find.A2(d.nextLine());
            }
            if(c==2){
                System.out.println("请输入作者:");
                Find.A3(d.nextLine());
            }
            if(c==3){
                System.out.println("请输入isbn码:");
                Find.A4(d.nextInt());
            }
            System.out.println("\n");
            }
        if(b==3){
            System.out.println("输入isbn码进行借阅:");
            Find.A5(d.nextInt());
            System.out.println("\n");
        }
        if(b==4){
            Find.A6();
            System.out.println("\n");
        }     
        if(b==5){
            System.out.println("输入isbn码进行还书操作:");
            Find.A7(d.nextInt());
            System.out.println("\n");
        }  
        if(b==6){
            for(book A:Book){
                System.out.println(Find.A1(A)+"\t借书者姓名:"+A.jieshu+"\t借书时间"+A.time);
            }
            System.out.println("\n");
            System.out.println("请输入你想操作的书籍数据的isbn码:");
            Find.A8(d.nextInt());
            System.out.println("\n");
        } 
        if(b==7){
           Find.A9();
           System.out.println("\n");
        } 
        if(b==8){
            Find.A10();
            System.out.println("\n");
        }
        if(b==0){
            System.out.println("系统退出成功!");
            break;
        }  
        }
    }
}
class book{
    String name;
    String zuozhe;
    int isbn;
    boolean Z=true;
    String jieshu;
    String time;
book(String a,String b,int c){
    name=a;
    zuozhe=b;
    isbn=c;
}
}
class find{
    book[] a;
    int c;
    find(book []b){
        c=b.length;
        a=new book[c];
        for(;c>0;c--){
        a[c-1]=new book(null,null,0);
        a[c-1]=b[c-1];
        }
    }
    String A1(book f){
        return "书名:"+f.name+"\t作者:"+f.zuozhe+"\tisbn号:"+f.isbn+"\t是否在馆:"+f.Z;
    }
    void A2(String b){
        String c=null;
        for(book A:a){
            if((A.name).equals(b)){
                c=A.name;
                System.out.println(A1(A));
            }
        }
        if(c==null)
        System.out.println("查无此书!");
    }
    void A3(String b){
        String c=null;
        for(book A:a){
            if((A.zuozhe).equals(b)){
                c=A.zuozhe;
                System.out.println(A1(A));
            }
        }
        if(c==null)
        System.out.println("查无此书!");
    }
    void A4(int b){
        int c=0;
        for(book A:a){
            if((A.isbn)==b){
                c=A.isbn;
                System.out.println(A1(A));
            }
        }
        if(c==0)
        System.out.println("查无此书!");
    } 
    void A5(int b){
        Scanner d=new Scanner(System.in);
        String c=null;
        for(book A:a){
            if(A.isbn==b&&A.Z==true){
                System.out.println("输入0确认借阅");
                if(d.nextInt()==0){
                    d.nextLine();
                    System.out.println("输入借阅者姓名:");
                    c=d.nextLine();
                    A.jieshu=c;
                    A.Z=false;
                    System.out.println("借书完成");
                    Date date = new Date();
                    System.out.println("借书时间是:");
                    System.out.println((new SimpleDateFormat("yyyy-MM-dd")).format(date));
                    A.time=(new SimpleDateFormat("yyyy-MM-dd")).format(date);
                    Calendar cal = Calendar.getInstance();
                    cal.setTime(date);
                    cal.add(Calendar.DATE, 30);
                    System.out.println("最迟还书时间是:");
                    System.out.println((new SimpleDateFormat("yyyy-MM-dd")).format(cal.getTime()));

                }
            }
        }
        if(c==null)
        System.out.println("查无此书,或此书已被借阅!");
    }
    void A6(){
        for(book A:a){
            if(A.Z==false)
            System.out.println("书名:"+A.name+"\t借阅者姓名:"+A.jieshu+"\t借书日期:"+A.time);
        }
    }
    void A7(int b){
        for(book A:a){
            if(A.isbn==b)
            A.Z=true;
            A.jieshu=null;
            System.out.println("成功还书!");
        }
    }
    void A8(int b){
        int c=5;
        Scanner d=new Scanner(System.in);
        for(book A:a){
            if((A.isbn)==b){
                while(true){
                c=A.isbn;              
                System.out.println("1.修改书名");
                System.out.println("2.修改作者");
                System.out.println("3.修改isbn码");
                System.out.println("4.修改借阅者姓名");
                System.out.println("5.修改借书日期");
                System.out.println("0.退出信息修改系统");
                c=d.nextInt();
                d.nextLine();
                if(c==1){
                    System.out.print("新书名:");
                    A.name=d.nextLine();
                    System.out.println("\n");
                }
                if(c==2){
                    System.out.print("新作者:");
                    A.zuozhe=d.nextLine();
                    System.out.println("\n");
                }
                if(c==3){
                    System.out.print("新isbn码:");
                    A.isbn=d.nextInt();
                    System.out.println("\n");
                }
                if(c==4){
                    System.out.print("新的借阅者姓名:");
                    A.jieshu=d.nextLine();
                    System.out.println("\n");
                }
                if(c==5){
                    System.out.print("新的借书日期:");
                    A.time=d.nextLine();
                    System.out.println("\n");
                }
                if(c==0){
                    break;
                }
                System.out.println("修改完成!");
            }
        }
        }
        if(c==5)
        System.out.println("查无此书!");
    }
    void A9(){
        try{
            Scanner d=new Scanner(System.in);
            int n;
            String str;
            char[] chars=new char[100];
            System.out.println("请输入你想备份的文件的名称:");
            File message=new File(d.nextLine()+".txt");
            FileWriter g=new FileWriter(message);
            FileReader e=new FileReader(message);
            for(book A:a){
                str=A1(A)+"\t借书者姓名:"+A.jieshu+"\t借书时间"+A.time+"\n";
                g.write(str.toCharArray());
                while((n=e.read(chars))!=-1){
                    new String(chars,0,n);
                }
            }
            System.out.println("信息备份成功!!!");
            g.close();
    }
    catch(IOException f){
        System.out.println("example:"+f);
        }
    }
    void A10(){
        String str1,str2;
        int I1,I2,b=0,c=0,e=0;
        Date date = new Date();
        System.out.println("当前时间是:");
        System.out.println((new SimpleDateFormat("yyyy-MM-dd")).format(date));
        str1=(new SimpleDateFormat("yyyy-MM-dd")).format(date);
        b=str1.length();
        System.out.println("应还书籍的信息为:");
        for(book A:a){
            if(A.time!=null){
            I1=0;
            I2=0;
            str2=A.time;
            c=0;
            for(;c<b;c++){
                I1=(int)str1.charAt(c);
                I2=(int)str2.charAt(c);
                if(I1<I2){
                    System.out.println(A1(A));
                    break;
                    }
                }
            }
        }
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值