返回顶部
首页 > 资讯 > 精选 >如何用Java代码实现图书管理系统
  • 124
分享到

如何用Java代码实现图书管理系统

2023-06-29 07:06:33 124人浏览 独家记忆
摘要

这篇文章主要介绍“如何用Java代码实现图书管理系统”,在日常操作中,相信很多人在如何用Java代码实现图书管理系统问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”如何用Java代码实现图书管理系统”的疑惑有所

这篇文章主要介绍“如何用Java代码实现图书管理系统”,在日常操作中,相信很多人在如何用Java代码实现图书管理系统问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”如何用Java代码实现图书管理系统”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

文件位置

AllBook

package tushuguan;import java.io.Serializable;import java.util.Scanner;//------------------------图书信息的代码--------------------------@SuppressWarnings("serial")class Book implements Serializable{ //图书类        String BookNo;              //编号        String BookName;            //书名        String BookAuthor;          //作者        int zk;                              //是否在库        int cs;                              //借阅次数        showInfo info=new showInfo();        //借阅信息日常显示    public Book(){                           //定义构造方法,初始化数据项            BookNo="";            BookName="";            BookAuthor="";                 zk=0;            cs=0;            }        public String getBookNo(){            return BookNo;        }        public String getBookName(){            return BookName;        }        public String getBookAuthor(){            return BookAuthor;        }           //````````````````````````新增图书信息``````````````````````````    public void inputBook(){                 //输入单个图书        @SuppressWarnings({"resource" })        Scanner in2=new Scanner(System.in);          System.out.print("请输入图书编号:");        String s;        s=in2.nextLine();        int a;        a=AllBook.queryBooByBookNo(s);        while(a!=-1){                            //判断是否已有相同编号的图书存在        System.out.print("该书籍已存在,请重新输入!\n");        System.out.print("请输入图书编号:");        s=in2.nextLine();        a=AllBook.queryBooByBookNo(s);        }        BookNo=s;        System.out.print("请输入图书名称:");        BookName=in2.nextLine();         System.out.print("请输入图书作者:");        BookAuthor=in2.nextLine();        zk=1;        }              public void showBook(){                        //显示单个图书信息    System.out.print("图书编号:"+BookNo+"\n图书名称:"+BookName+"\n图书作者:"+BookAuthor+"\n借阅次数:"+cs);            if(zk==1)                System.out.print("\n该图书:在库\n");            else                System.out.print("\n该图书: 不在库\n");           }                }           @SuppressWarnings("serial")public class AllBook  implements Serializable{      //所有图书集合类         static Book []Book=new Book[20];       //定义一个能存储20个图书的数组对象        static int index=0;                                                  //用于存储当前已有图书的数量    public  AllBook(){                     //初始化所有单元的图书信息;        for(int i=0;i<Book.length;i++){            Book[i]=new Book();            }    }    //---------------输入多个图书信息--------------------    public void inputAB(){                              int a=1;        for(int i=index;i<Book.length;i++){            if(a==1){             System.out.print("下面录入第"+(index+1)+"本图书的信息:\n");            Book[index].inputBook();             index++;             System.out.print("继续添加请按1,停止添加请按0:");                int b;                @SuppressWarnings("resource")             Scanner in1=new Scanner(System.in);                b=in1.nextInt();               switch(b){               case 0: a=0;break;               default: break;                        }                    }         }                    }          //`````````````````````````浏览多个图书信息````````````````````````    public void showAllBook(){//显示所有图书信息        System.out.print("共有"+index+"本书");            for(int i=0;i<index;i++){                System.out.print("\n下面输出第"+(i+1)+"本书的信息:\n");            Book[i].showBook();                           }            if(index==0){                System.out.print("没有图书信息!");            }        }    //**************************************    public void queryByBookNo(){                 //1.按编号查询            String a;            @SuppressWarnings("resource")            Scanner in2=new Scanner(System.in);            System.out.print("请输入要查询的图书编号:");            a=in2.nextLine();            if(queryBooByBookNo(a)!=-1){            System.out.print("该图书信息为:\n");            Book[queryBooByBookNo(a)].showBook();            }            else                                 System.out.print("该图书不存在!");                   }    public static int queryBooByBookNo(String s){//按编号查询,s为查询的图书编号;若找到,则返回该信息的位置,否则返回-1            int flag=-1;            for(int i=0;i<index;i++){                if(s.equals(Book[i].BookNo)){                    flag=i;break;                }            }    return flag;        }    //****************************************            public void queryByBookName(){               //2.按名称查询            String a;            @SuppressWarnings("resource")            Scanner in1=new Scanner(System.in);            System.out.print("请输入要查询的图书名称:");            a=in1.nextLine();            if(queryBooByBookName(a)!=-1){            System.out.print("该图书信息为:\n");            Book[queryBooByBookName(a)].showBook();            }            else                                 System.out.print("该图书不存在!");                                  }    public int queryBooByBookName(String s){      //按名称查询,s为查询的图书名称;若找到,则返回该信息的位置,否则返回-1            int flag=-1;            for(int i=0;i<index;i++){                if(s.equals(Book[i].BookName)){                    flag=i;break;                }            }            return flag;        }    //*************************************    public void queryByBookAuthor(){                 //3.按作者查询            String a;            @SuppressWarnings("resource")        Scanner in1=new Scanner(System.in);            System.out.print("请输入要查询的图书作者:");            a=in1.nextLine();            if(queryBooByBookAuthor(a)!=-1){             System.out.print("该图书信息为:\n");            Book[queryBooByBookAuthor(a)].showBook();            }            else                                System.out.print("该图书不存在!");                                }    public int queryBooByBookAuthor(String s){      //按作者查询,s为查询的图书作者;若找到,则返回该信息的位置,否则返回-1            int flag=-1;            for(int i=0;i<index;i++){                if(s.equalsIgnoreCase(Book[i].BookAuthor)){                    flag=i;break;                }            }            return flag;        }            //```````````````````````删除图书信息``````````````````````````    public void deleteByBookNo(){                  //删除指定编号的图书信息   String b;   @SuppressWarnings("resource")   Scanner in2=new Scanner(System.in);   System.out.print("请输入要删除图书的编号");   b=in2.nextLine();    if (queryBooByBookNo(b)!=-1){                    //判断该图书是否存在                  for(int i=queryBooByBookNo(b);i<index-1;i++){                  Book[i]=Book[i+1];                          }                   System.out.print("删除成功!");                  index--;                  }    else        System.out.print("该图书不存在!");           }    //```````````````````````修改图书信息``````````````````````````        @SuppressWarnings("resource")    public void reviseByBookNo(){                  // 按编号查找该图书并修改图书内容        String b;        int n;    Scanner in2=new Scanner(System.in);    Scanner in3=new Scanner(System.in);    System.out.print("请输入要修改的图书编号");    b=in3.nextLine();                        if(queryBooByBookNo(b)!=-1){         //判断该图书是否存在                        int i=queryBooByBookNo(b);                        System.out.println("请选择要修改的图书信息:");                        System.out.println("1-修改图书编号");                        System.out.println("2-修改图书名称");                        System.out.println("3-修改图书作者");                        System.out.println("4-修改所有信息");                         n=in2.nextInt();                         while(n<0||n>4){                                System.out.print("该数字无效,请重新选择:");                                n=in2.nextInt();}                switch(n){                case 1:{                                                     System.out.println("请输入修改后的图书编号:");                         Book[i].BookNo=in3.nextLine();    break;                         }                case 2:{                        System.out.println("请输入修改后的图书名称:");                        Book[i].BookName=in3.nextLine();break;                         }                case 3:{                       System.out.println("请输入修改后的图书作者:");                       Book[i].BookAuthor=in3.nextLine();break;                         }                case 4:{                       System.out.println("请输入修改后的图书编号、图书名称 、图书作者:");                       System.out.println("请输入修改后的图书编号:");                       Book[i].BookNo=in3.nextLine();                       System.out.println("请输入修改后的图书名称:");                       Book[i].BookName=in3.nextLine();                       System.out.println("请输入修改后的图书作者:");                       Book[i].BookAuthor=in3.nextLine();                }                         } System.out.print("修改成功!");                      }                    else                    System.out.print("该图书不存在!");                }                               }

AllBorrow

package tushuguan;import java.io.Serializable;import java.util.Scanner;class showInfo {                 //定义一个借阅信息显示类       String lendtime;            //借书日期       String returntime;          //还书日期       String lendStuNo;           //借书学生编号       String lendStuName;         //借书学生姓名       String lendStuClass;        //借书学生班级       public showInfo(){          //定义构造方法,初始化数据项               lendtime="";                           returntime="";           lendStuNo="";           lendStuName="";           lendStuClass="";       }}@SuppressWarnings("serial")class Borrow implements Serializable{//借阅类     static int BoCs;                //最大的借阅次数     String StudentNo;     String BookNo;    public Borrow(){          //定义构造方法,初始化数据项                         BoCs=0;             StudentNo="";             BookNo="";            }}@SuppressWarnings("serial")class AllBorrow  implements Serializable{//所有借阅类            //-----------------显示借阅信息---------------         public void showlendInfo(String BookNo){          int a=AllBook.queryBooByBookNo(BookNo);      //找到该编号对应的图书下标赋值给a          System.out.print("\n该图书的借阅信息为:");                   System.out.print("\n该借书学生学号为:"+AllBook.Book[a].info.lendStuNo);          System.out.print("\n该借书学生姓名为:"+AllBook.Book[a].info.lendStuName);          System.out.print("\n该借书学生班级为:"+AllBook.Book[a].info.lendStuClass);          System.out.print("\n该图书的借出日期:"+AllBook.Book[a].info.lendtime);              }    //---------------显示归还信息------------------    public void showlendReturn(String BookNo){          int a=AllBook.queryBooByBookNo(BookNo);      //找到该编号对应的图书下标赋值给a          System.out.print("\n该图书的归还信息为:");                   System.out.print("\n该借书学生学号为:"+AllBook.Book[a].info.lendStuNo);          System.out.print("\n该借书学生姓名为:"+AllBook.Book[a].info.lendStuName);          System.out.print("\n该借书学生班级为:"+AllBook.Book[a].info.lendStuClass);          System.out.print("\n该图书的借出日期:"+AllBook.Book[a].info.lendtime);          System.out.print("\n该图书的归还日期:"+AllBook.Book[a].info.returntime);     }    //----------------------多本图书借阅----------------        @SuppressWarnings("resource")    public void Alllend(){         Scanner in1=new  Scanner(System.in);         Scanner in2=new Scanner(System.in);         int a=0,b=0;         String StudentNo,BookNo,d;         int c=1;         System.out.print("请输入你的学号:");            StudentNo=in1.nextLine();                      b=AllStudent.queryStuByStudentNo(StudentNo);            if(b!=-1){                 //判断该学生是否存在                       System.out.print("登录成功!\n");                       while(c==1){                         System.out.print("请查询要借阅的图书\n");                                     System.out.print("请输入该书编号:");                                 BookNo=in1.nextLine();                         a=AllBook.queryBooByBookNo(BookNo);                         if(a!=-1){   //判断图书是否存在                          if(AllBook.Book[a].zk==1){        //判断图书是否在库                               AllBook.Book[a].showBook();                              System.out.print("\n该图书在库,请填写借阅信息:");                          AllBook.Book[a].zk=0;      //借出图书,将图书的在库信息修改为不在库                          AllBook.Book[a].cs++;      //借出图书,该图书借阅次数加一                          AllBook.Book[a].info.lendStuNo=AllStudent.Student[b].StudentNo;                          AllBook.Book[a].info.lendStuName=AllStudent.Student[b].StudentName;                          AllBook.Book[a].info.lendStuClass=AllStudent.Student[b].StudentClass;                          System.out.print("\n请填写借出日期(xxxxxxxx):");                          d=in1.nextLine();                          while(d.length()!=8){     //判断日期格式是否正确                              System.out.print("日期格式错误,请重新输入8个字符的借书日期(如20180101)");                              System.out.print("\n请重新填写归还日期:");                              d=in1.nextLine();                        }                         AllBook.Book[a].info.lendtime=d;                         System.out.print("借阅成功!");                                                   }                          else                             System.out.print("图书不在库,借阅失败!");                         }                         else                              System.out.print("图书不存在,借阅失败!");                                                          System.out.print("\n是否继续借阅:1-是,0-否");                              c=in2.nextInt();                    switch(c){                        case 0: c=0;break;                       default: break;                               }                 }            }            else              System.out.print("该学生信息不存在!\n");                  }         //---------------归还图书管理(单本)---------    @SuppressWarnings("resource")    public void returnBook(){         Scanner in1=new Scanner(System.in);         Scanner in2=new Scanner(System.in);         System.out.print("请输入归还图书的编号:");         String BookNo,b;         BookNo=in1.nextLine();         int a=AllBook.queryBooByBookNo(BookNo);         if(a!=-1){          if(AllBook.Book[a].zk==0){                          System.out.print("\n请填写归还日期(xxxxxxxx):");             b=in2.nextLine();            if(b.length()!=8){   //判断日期格式             while (b.length()!=8){                          System.out.print("归还日期出错!");                   System.out.print("\n请重新填写归还日期,例如20180101:");                  AllBook.Book[a].info.returntime=in2.nextLine();            }}                    else              while(AllBook.Book[a].info.returntime.compareTo(AllBook.Book[a].info.lendtime)<=0){              System.out.print("归还时间不对,请输入不小于借阅日期的日期");              System.out.print("\n请重新填写归还日期:");              AllBook.Book[a].info.returntime=in2.nextLine();            }            AllBook.Book[a].zk=1;              System.out.print("归还成功!");               showlendReturn(BookNo);}          else              System.out.print("该图书在库不需要归还!");         }         else             System.out.print("不存在该图书!");              }            //--------------------多本图书归还-------------------    @SuppressWarnings("resource")    public void Allreturn(){     int c=1;     Scanner in1=new  Scanner(System.in);          while(c==1){            returnBook();             System.out.print("\n\n是否继续归还:1-是,0-否");                      c=in1.nextInt();            switch(c){             case 0: c=0;break;             case 1: break;            default: break;                    }             }          }        //----------------按借阅次数查询-------------------    public int  findBoCs(){  //找到最大的借阅次数     for(int i=0;i<AllBook.index;i++){         if(Borrow.BoCs<AllBook.Book[i].cs){             Borrow.BoCs=AllBook.Book[i].cs;         }              }return Borrow.BoCs;}    public void findByTj(){   //按借阅次数查询     int a= findBoCs();     int c=0;    System.out.print("最大借阅次数为"+a+",请输入要查询的借阅次数:");    @SuppressWarnings("resource")    Scanner in1=new Scanner(System.in);    int b;    b=in1.nextInt();        if(b<=a){         System.out.print("\n借阅次数为"+b+"的图书信息如下:\n");         for(int  i=0;i<AllBook.index;i++){          if(AllBook.Book[i].cs==b){            AllBook.Book[i].showBook();             c++;             }          }           if(c==0){              System.out.print("\n不存在借阅次数为"+b+"的图书");             }          }    else    System.out.print("该借阅次数超过最大借阅次数!");}        //-------------------显示所有在库图书----------------    public void showzkBook(){        int c=0;        System.out.print("所有在库的图书信息为:\n");        for(int  i=0;i<AllBook.index;i++){            if(AllBook.Book[i].zk==1){                AllBook.Book[i].showBook();                c++;            }        }        if(c==0){            System.out.print("无在库图书!");        }    }    //-------------------显示所有不在库图书----------------    public void showbzkBook(){        int c=0;        System.out.print("所有不在库的图书信息为:\n");        for(int  i=0;i<AllBook.index;i++){            if(AllBook.Book[i].zk==0){                AllBook.Book[i].showBook();                c++;            }        }        if(c==0){        System.out.print("无不在库图书!");        }    }      //----------------------图书查询管理----------------------    public void findbook(){     @SuppressWarnings("resource")    Scanner in=new Scanner(System.in);     String b;     System.out.print("请输入要查找图书的编号:\n");     b=in.nextLine();     int a=AllBook.queryBooByBookNo(b);    if(a!=-1){      if(AllBook.Book[a].zk==1)                       AllBook.Book[a].showBook();          else          {          AllBook.Book[a].showBook();          showlendInfo(b);   }         }    else         System.out.print("图书不存在!");     }}

AllStudent

package tushuguan;import java.io.Serializable;import java.util.Scanner;    @SuppressWarnings("serial")class Student implements Serializable{ //学生类           String StudentNo;    //学号           String StudentName;  //书名           String StudentClass; //班级                    public Student(){//定义构造方法,初始化数据项               StudentNo="";               StudentName="";               StudentClass="";                        }           public String getStudentNo(){               return StudentNo;           }           public String getStudentName(){               return StudentName;           }           public String getStudentClass(){               return StudentClass;           }                     //````````````````````````新增学生信息``````````````````````````       public void inputStudent(){//输入单个学生               @SuppressWarnings("resource")            Scanner in2=new Scanner(System.in);               System.out.print("请输入学生学号:");               String s;               s=in2.nextLine();               int a;            a=AllStudent.queryStuByStudentNo(s);            while(a!=-1){         //判断是否已经存在该学号的学生             System.out.print("该学生已存在,请重新输入!\n");             System.out.print("请输入学生学号:");             s=in2.nextLine();             a=AllStudent.queryStuByStudentNo(s);            }            StudentNo=s;               System.out.print("请输入学生名称:");               StudentName=in2.nextLine();               System.out.print("请输入学生班级:");               StudentClass=in2.nextLine();                         }    public void showStudent(){//显示单个学生信息               System.out.print("学生学号:"+StudentNo+"\n学生名称:"+StudentName+"\n学生班级:"+StudentClass);                  }               }           @SuppressWarnings("serial")public class AllStudent implements Serializable{                      //所有学生集合类            static Student []Student=new Student[20];                     //定义一个能存储20个学生的数组对象           static int index=0;                                                  //用于存储当前已有学生的数量           public  AllStudent(){                                        //初始化所有单元的学生信息;            for(int i=0;i<Student.length;i++){               Student[i]=new Student();               }           }       //----------------输入多个学生信息---------------       public void inputAS(){            int a=1;               for(int i=index;i<Student.length;i++){               if(a==1){                  System.out.print("下面录入第"+(index+1)+"个学生的信息:\n");                Student[i].inputStudent();                index++;                System.out.print("继续添加请按1,停止添加请按0:");                   int b;                   @SuppressWarnings("resource")                Scanner in1=new Scanner(System.in);                   b=in1.nextInt();                   switch(b){                   case 0: a=0;break;                   default: break;                               }                       }            }                      }           //`````````````````````````浏览学生信息````````````````````````       public void showAllStudent(){//显示所有学生信息               for(int i=0;i<index;i++){                   System.out.print("\n下面输出第"+(i+1)+"个学生的信息:\n");                Student[i].showStudent();                             }               if(index==0){                   System.out.print("没有学生信息!");               }           }            @SuppressWarnings("resource")    public void queryByStudentNo(){                 //1.按学号查询               String a;               int c;               Scanner in1=new Scanner(System.in);               System.out.print("请输入要查询的学生编号:");               a=in1.nextLine();               c=queryStuByStudentNo(a);               if(c!=-1){                System.out.print("该学生信息为:\n");             Student[queryStuByStudentNo(a)].showStudent();               }               else                                     System.out.print("该学生不存在!");                                  }       public static int queryStuByStudentNo(String s){//按学号查询,s为查询的学生学号;若找到,则返回该信息的位置,否则返回-1               int flag=-1;               for(int i=0;i<index;i++){                   if(s.equalsIgnoreCase(Student[i].StudentNo)){                       flag=i;break;                   }               }               return flag;           }    //*******************************************           @SuppressWarnings("resource")    public void queryByStudentName(){                 //2.按名字查询               String a;               Scanner in1=new Scanner(System.in);               System.out.print("请输入要查询的学生名字:");               a=in1.nextLine();               if(queryStuByStudentName(a)!=-1){                System.out.print("该学生信息为:\n");              Student[queryStuByStudentName(a)].showStudent();               }               else                               System.out.print("该学生不存在!");                                     }       public int queryStuByStudentName(String s){       //按名字查询,s为查询的学生名字;若找到,则返回该信息的位置,否则返回-1               int flag=-1;               for(int i=0;i<index;i++){                   if(s.equalsIgnoreCase(Student[i].StudentName)){                       flag=i;break;                   }                   else                       continue;               }               return flag;           }       //*******************************************           @SuppressWarnings("resource")    public void queryByStudentClass(){                 //3.按班级查询               String a;               Scanner in1=new Scanner(System.in);               System.out.print("请输入要查询的学生班级:");               a=in1.nextLine();               if(queryStuByStudentClass(a)!=-1){                System.out.print("该学生信息为:\n");              Student[queryStuByStudentClass(a)].showStudent();               }               else                                    System.out.print("该学生不存在!");                                     }       public int queryStuByStudentClass(String s){         //按班级查询,s为查询的学生班级;若找到,则返回该信息的位置,否则返回-1               int flag=-1;               for(int i=0;i<index;i++){                   if(s.equalsIgnoreCase(Student[i].StudentClass)){                       flag=i;break;                   }                   else                       continue;               }               return flag;           }                //```````````````````````删除学生信息``````````````````````````        @SuppressWarnings("resource")    public void deleteByStudentNo(){                  //删除指定学号的学生信息         String b;         Scanner in2=new Scanner(System.in);         System.out.print("请输入要删除学生的学号");         b=in2.nextLine();          if (queryStuByStudentNo(b)!=-1){                        for(int i=queryStuByStudentNo(b);i<index;i++){                        Student[i]=Student[i+1];                                              }                          index--;                        System.out.print("删除成功!");                        }          else              System.out.print("该学生不存在!");                }             //```````````````````````修改学生信息``````````````````````````     @SuppressWarnings("resource")    public void reviseByStudentNo(){          // 按编号查找该图书并修改图书内容            String b;            int n;         Scanner in2=new Scanner(System.in);         Scanner in3=new Scanner(System.in);         System.out.print("请输入要修改的学生编号:");         b=in2.nextLine();                              if(queryStuByStudentNo(b)!=-1){                                  int i=queryStuByStudentNo(b);                          System.out.println("请选择要修改的学生信息:");                          System.out.println("1-修改学生学号");                          System.out.println("2-修改学生姓名");                          System.out.println("3-修改学生班级");                          System.out.println("4-修改所有信息");                           n=in2.nextInt();                          while(n<0||n>4){                              System.out.print("该数字无效,请重新选择:");                              n=in2.nextInt();}                           switch(n){                  case 1:{                                                        System.out.println("请输入修改后的学生学号:");                          Student[i].StudentNo=in3.nextLine();    break;                           }                  case 2:{                          System.out.println("请输入修改后的学生姓名:");                          Student[i].StudentName=in3.nextLine();break;                           }                  case 3:{                          System.out.println("请输入修改后的学生班级:");                          Student[i].StudentClass=in3.nextLine();break;                              }                  case 4:{                          System.out.println("请输入修改后的学生学号、姓名、班级:");                          System.out.println("请输入修改后的学生学号:");                          Student[i].StudentNo=in3.nextLine();                          System.out.println("请输入修改后的学生姓名:");                        Student[i].StudentName=in3.nextLine();                        System.out.println("请输入修改后的学生班级:");                          Student[i].StudentClass=in3.nextLine();                  }                           } System.out.print("修改成功!");                        }                      else                      System.out.print("该学生不存在!");                  }                                }

Tushu

package tushuguan;import java.io.Serializable;import java.util.Scanner;        @SuppressWarnings("unused")class Menu{//菜单类        AllBook Book=new AllBook();        AllStudent Student=new AllStudent();        AllBorrow Borrow= new AllBorrow();                 public void showMenu(){//主菜单部分               System.out.println("******系部图书成绩管理系统*******");               System.out.println("**     1.图书信息管理                   **");               System.out.println("**     2.学生信息管理                   **");               System.out.println("**     3.借阅信息管理                   **");               System.out.println("**     0.退出总管理系统                **");               System.out.println("***************************");               System.out.println("请选择: ");               selectMenu();           }           public void selectMenu(){//选择主菜单部分               @SuppressWarnings("resource")            Scanner in1=new Scanner(System.in);               int a;               a=in1.nextInt();               while(a<0||a>3){                   System.out.print("该数字无效,请重新选择:");                   a=in1.nextInt();               }               switch (a){               case 1:{showMBook();break;}               case 2:{showMStudent();break;}               case 3:{showMBorrow();break;}             case 0:{System.out.print("******感谢您的使用!******");}               }           }           //-------------------------图书信息管理目录-----------------------------            public void showMBook(){//图书信息管理目录                    System.out.println("\n*******图书信息管理目录******");               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("**       0.退出总管理系统          **");               System.out.println("************************************");               System.out.println("请选择:");               selectMBook();           }           public void selectMBook(){//选择图书目录               @SuppressWarnings("resource")            Scanner in1=new Scanner(System.in);               int b;               b=in1.nextInt();               while(b>6||b<0){                   System.out.print("该数字无效,请重新选择:");                   b=in1.nextInt();               }               switch (b){               case 1:{                                   Book.inputAB();                  //新增图书信息                                   System.out.print("\n完成图书信息新增操作.\n");                                   showMBook();break;}               case 2:{                                                                                                              findBook();                 //查找图书信息                                   System.out.print("\n完成图书信息查询操作.\n");                                   showMBook();break;}                          case 3:{                                                                               Book.deleteByBookNo();           //删除图书信息                                  System.out.print("\n完成图书信息删除操作.\n");                                  showMBook();break;}               case 4:{                                                                                Book.showAllBook();              //浏览图书信息                                                                     System.out.print("\n完成图书信息浏览操作.\n");                                  showMBook();break;}               case 5:{                                                                               Book.reviseByBookNo();        //修改图书信息                                  System.out.print("\n完成图书信息修改操作.\n");                                  showMBook();break;}               case 6:{                                                                              showMenu();}                         //返回上一界面                              case 0:{           System.out.print("\n******感谢您的使用!******");System.exit(0);}                 }              }      //`````````````````````````查询图书信息````````````````````````        public void findBook(){               System.out.print("\n请选择查找图书方式:\n");               System.out.println("*******查找图书方式******");               System.out.println("**       1.按图书编号查找                 **");               System.out.println("**       2.按图书名称查找                 **");               System.out.println("**       3.按图书作者查找                 **");               System.out.println("**       0.返回上一菜单                     **");               @SuppressWarnings("resource")              Scanner in2=new Scanner(System.in);                       int c;                      c=in2.nextInt();                      while(c<0||c>3){                             System.out.print("该数字无效,请重新选择:");                             c=in2.nextInt();}                      switch(c){                      case 1:{                          Book.queryByBookNo();break;        //按编号查询图书信息                                     }                      case 2:{                          Book.queryByBookName(); break;     //按书名查询图书信息                                    }                      case 3:{                          Book.queryByBookAuthor(); break;   //按作者查询图书信息                                     }                      case 0:{                                showMBook();}}            }      //-------------------------学生信息管理目录-----------------------------        public void showMStudent(){//学生信息管理目录                  System.out.println("\n*******学生信息管理目录******");           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("**       0.退出总管理系统       **");           System.out.println("*************************");           System.out.println("请选择:");           selectMStudent();       }         public void selectMStudent(){//选择学生目录           @SuppressWarnings("resource")        Scanner in1=new Scanner(System.in);           int b;           b=in1.nextInt();                while(b<0||b>6){               System.out.print("该数字无效,请重新选择:");               b=in1.nextInt();           }           switch (b){           case 1:{                             Student.inputAS();               //新增学生信息                             System.out.print("\n完成学生信息新增操作\n");                             showMStudent();break;}           case 2:{                             findStudent();           //查找学生信息                             System.out.print("\n完成学生信息查询操作\n");                             showMStudent();break;}                  case 3:{                                                                                                                    Student.deleteByStudentNo();       //删除学生信息                                                                              System.out.print("\n完成学生信息删除操作\n");                             showMStudent();break;}           case 4:{                             Student.showAllStudent();     //浏览学生信息                                                                        System.out.print("\n完成学生信息浏览操作\n");                             showMStudent();break;}           case 5:{                                                                                                                                 Student.reviseByStudentNo();//修改图书信息                             System.out.print("\n完成学生信息修改操作\n");                          showMStudent();break;}           case 6:{                             showMenu();    }                      //返回主菜单                      case 0:{          System.out.print("\n******感谢您的使用!******");System.exit(0);}              }         }        //`````````````````````````查询学生信息````````````````````````           @SuppressWarnings("resource")    public void findStudent(){                  System.out.print("\n请选择查找学生方式:\n");               System.out.println("***********查找学生方式**********");               System.out.println("**       1.按学生学号查找                 **");               System.out.println("**       2.按学生名称查找                 **");               System.out.println("**       3.按学生班级查找                 **");               System.out.println("**       0.返回上一菜单                      **");               Scanner in2=new Scanner(System.in);               int c;               c=in2.nextInt();               while(c<0||c>3){                   System.out.print("该数字无效,请重新选择:");                   c=in2.nextInt();}      switch(c){                  case 1:{                        Student.queryByStudentNo();break;      //按学号查询学生信息                                    }                  case 2:{                        Student.queryByStudentName(); break;   //按姓名查询学生信息                                   }                  case 3:{                       Student.queryByStudentClass(); break;   //按班级查询学生信息                                   }                  case 0:{ showMStudent();}               }                              }      //-------------------------图书借阅信息管理目录-----------------------------        public void showMBorrow(){        System.out.println("\n*******借阅图书信息管理目录*****");        System.out.println("**       1.图书借阅管理                **");        System.out.println("**       2.图书归还管理                **");                   System.out.println("**       3.图书查询管理                **");           System.out.println("**       4.统计查询管理                **");                   System.out.println("**       5.返回上一菜单                **");           System.out.println("**       0.退出总管理系统             **");           System.out.println("**********************************");           System.out.println("请选择:");           selectMBorrow();       }        public void selectMBorrow(){//选择图书目录           @SuppressWarnings("resource")        Scanner in1=new Scanner(System.in);           int b;           b=in1.nextInt();           while(b<0||b>5){               System.out.print("该数字无效,请重新选择:");               b=in1.nextInt();}           switch(b){           case 1:{                    Borrow.Alllend();          //图书借阅管理                   System.out.print("\n完成图书借阅操作\n");                showMBorrow();break;                                       }           case 2:{                   Borrow.Allreturn();       //图书归还管理                System.out.print("\n完成图书借阅操作\n");                showMBorrow();break;                 }                     case 3:{                   Borrow.findbook();       //图书查询管理                   System.out.print("\n完成图书查询操作\n");                showMBorrow();break;             }           case 4:{               TjfindBook();     //统计查询管理               System.out.print("\n完成图书统计查询操作\n");               showMBorrow();break;              }           case 5:{   showMenu();      }     //返回主菜单           case 0:{   System.out.print("\n******感谢您的使用!******");System.exit(0);}                     }        }    //-------------------统计查询管理--------------------------    public void TjfindBook(){     System.out.println("请选择统计查询的方式:\n");     System.out.println("1-按借阅次数查询");     System.out.println("2-按在库与否查询");     System.out.println("0-返回上一菜单  ");     @SuppressWarnings("resource")          Scanner in1 =new Scanner(System.in);     int a;     a=in1.nextInt();     while(a<0||a>3){            System.out.print("该数字无效,请重新选择:");            a=in1.nextInt();}     switch(a){     case 1:{                   Borrow.findByTj();      //按借阅次数查询                   System.out.print("\n完成统计查询图书操作\n");                   showMBorrow();break;                                 }     case 2:{                   findByzk();            //按是否在库查询                   System.out.print("\n完成统计查询图书操作\n");                   showMBorrow();break;                                  }     case 0:{      showMBorrow();}  //返回上一菜单     }}    //--------------按是否在库查询图书----------------------    public void findByzk(){             System.out.print("请选择在库模式查询:\n");             System.out.println("1-显示所有在库图书");             System.out.println("2-显示所有不在库图书");             System.out.println("0-返回上一菜单");                   @SuppressWarnings("resource")             Scanner in1 =new Scanner(System.in);             int a;             a=in1.nextInt();             while(a<0||a>3){                    System.out.print("该数字无效,请重新选择:");                    a=in1.nextInt();}             switch(a){             case 1:{                  Borrow.showzkBook();break;  //显示所有在库图书             }             case 2:{                  Borrow.showbzkBook();break;  //显示所有不在库图书             }             case 0:{ showMBorrow();}             }        }}public class Tushu{    public static void main(String []args){        Menu menu =new Menu();        menu.showMenu();    }}

到此,关于“如何用Java代码实现图书管理系统”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注编程网网站,小编会继续努力为大家带来更多实用的文章!

--结束END--

本文标题: 如何用Java代码实现图书管理系统

本文链接: https://lsjlt.com/news/323442.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

猜你喜欢
  • 如何用Java代码实现图书管理系统
    这篇文章主要介绍“如何用Java代码实现图书管理系统”,在日常操作中,相信很多人在如何用Java代码实现图书管理系统问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”如何用Java代码实现图书管理系统”的疑惑有所...
    99+
    2023-06-29
  • java如何实现图书管理系统
    小编给大家分享一下java如何实现图书管理系统,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!一、背景介绍通过一段时间java编程的学习,需要一个比较综合的实例来进...
    99+
    2023-06-14
  • Java实现图书管理系统的示例代码
    目录一、功能介绍二、Main包三、User包1. User2. AdminUser3. NormalUser四、book包1. Book2. BookList五、operations...
    99+
    2024-04-02
  • 如何使用Java实现图书管理系统
    本篇内容介绍了“如何使用Java实现图书管理系统”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!一. 功能介绍1.1 使用介绍1.输入姓名2....
    99+
    2023-07-02
  • Eclipse+Java+Swing实现图书管理系统(详细代码)
    目录一、系统介绍二、系统展示1.注册2.登录5.管理员端-添加图书类别6.管理员端-修改图书类别7.管理员端-添加图书8.管理员端-修改图书9.管理员端-管理用户信息10.管理员端-...
    99+
    2024-04-02
  • java实现图书管理系统
    本文通过实例为大家分享了java实现图书管理系统的具体代码,供大家参考,具体内容如下 一、背景介绍 通过一段时间java编程的学习,需要一个比较综合的实例来进行编程的练习,是一个对前...
    99+
    2024-04-02
  • 怎么用C++代码实现图书馆管理系统
    这篇“怎么用C++代码实现图书馆管理系统”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇“怎么用C++代码实现图书馆管理系统”文...
    99+
    2023-06-29
  • JavaSE实现图书管理系统的示例代码
    目录前言1. 项目需求2. 实现思路3. 代码实现包的设计book包operations包user包4. 实现效果前言 这篇博客是在学习了一部分Java基础语法之后的练习项目,通过这...
    99+
    2024-04-02
  • C++如何实现图书管理系统
    本文小编为大家详细介绍“C++如何实现图书管理系统”,内容详细,步骤清晰,细节处理妥当,希望这篇“C++如何实现图书管理系统”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。功能:首先是注册,登录,找回密码和修改密码...
    99+
    2023-06-29
  • C#如何实现图书管理系统
    本文小编为大家详细介绍“C#如何实现图书管理系统”,内容详细,步骤清晰,细节处理妥当,希望这篇“C#如何实现图书管理系统”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。一、设计目的通过模拟图书管理系统,实现以下功能...
    99+
    2023-06-29
  • Java如何实现网上图书馆管理系统
    小编给大家分享一下Java如何实现网上图书馆管理系统,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!一、项目简述功能: 区分为管理员用户和普通用户,普通用户:用户登录,个 人信息修改,图书查询,用户借阅,用户归还,管理员用 ...
    99+
    2023-06-25
  • 怎么用Java实现图书管理系统
    这篇文章主要讲解了“怎么用Java实现图书管理系统”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“怎么用Java实现图书管理系统”吧!目录设计准备一、系统开发目的和意义二、系统总体设计主页:系...
    99+
    2023-06-20
  • C++实现图书管理系统源码
    本文实例为大家分享了C++实现图书管理系统的具体代码,供大家参考,具体内容如下 直接上代码 #include <stdafx.h> #include <iostr...
    99+
    2024-04-02
  • java实现简单图书管理系统
    本文实例为大家分享了java实现简单图书管理系统的具体代码,供大家参考,具体内容如下 JAVA练习的作业,题目如下: 设计一个图书管理系统类和用户类,要求具有以下功能: (1). 查...
    99+
    2024-04-02
  • Java怎么实现图书管理系统
    本篇内容主要讲解“Java怎么实现图书管理系统”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Java怎么实现图书管理系统”吧!一、项目简述功能包括(管理员和学生角色): 管理员和学生登录,图书管...
    99+
    2023-06-21
  • JAVA实现图书管理系统项目
    目录前言项目需求设计前提设计目标设计结构图功能解读项目实现基本对象的设置通过IO流的写入写出总结前言 相信再每一个学生在学习编程的时候,应该都会写的一个小项目——图书管理系统。为什么...
    99+
    2024-04-02
  • python实现图书管理系统的代码怎么写
    这篇文章主要介绍“python实现图书管理系统的代码怎么写”,在日常操作中,相信很多人在python实现图书管理系统的代码怎么写问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”python实现图书管理系统的代码...
    99+
    2023-06-29
  • 如何实现C++版图书管理系统
    这篇文章主要介绍了如何实现C++版图书管理系统,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。具体内容如下使用介绍图书管理系统源码由两部分组成,第一部分book.h头文件,第二...
    99+
    2023-06-29
  • C++实现图书馆管理系统源码
    本文实例为大家分享了C++实现图书馆管理系统的具体代码,供大家参考,具体内容如下 总体思想 用C++开发图书馆管理系统需要对学生和图书分别建立class,调用class中的方法实现学...
    99+
    2024-04-02
  • java实现简单的图书管理系统
    本文实例为大家分享了java实现简单的图书管理系统的具体代码,供大家参考,具体内容如下 一、项目分布 Book类: 定义了书的一些属性(书名,作者,价格,分类,状态)并且写了属性的...
    99+
    2024-04-02
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作