用java实现的简单管理系统

运行出来的状态

java一个简单的管理系统

 

实现了新增、删除、借出、归还、排行榜简单的功能!

下面是简单的代码

首先定义一个书籍类,自己打开哦!

 1  public class Book implements Comparable{
 2     
 3      String name;
 4      String date;
 5      boolean state;
 6      int count;
 7      
 8      public Book(String name,boolean state,String date,int count){
 9          
10          this.name=name;
11          this.date=date;
12          this.state=state;
13          this.count=count;
14      }
15      //复写toString方法为了打印出书的具体属性
16      public String toString(){
17          
18          if(this.state==true){
19            return (this.name+"\t"+"已借出"+"\t"+this.date);
20          }else{
21             return (this.name+"\t"+"可借"+"\t"+" ");
22          }     
23      }
24      //复写equals方法为了比较对象
25      public boolean equals(Object obj){
26          
27          Book bk=(Book)obj;
28          if(this.name.equals(bk.name) && this.state==bk.state){
29               return true;
30          }else{
31              return false; 
32          }
33         // return this.name.equals(bk.name);
34      }
35      //复写了equlasf方法必须复写此方法
36      public int hashCode(){
37          return this.name.hashCode();
38      }
39      //复写compareTo方法,为对象规定排序规则
40      public int compareTo(Object obj){
41          
42          Book bk=(Book)obj;
43         return bk.count-this.count;
44          
45      }
46       
47 }
定义书籍类

相关文章:

  • 2021-06-30
  • 2021-05-13
  • 2021-07-19
  • 2022-12-23
  • 2021-12-18
  • 2021-04-12
  • 2021-04-18
猜你喜欢
  • 2022-12-23
  • 2021-11-27
  • 2021-10-10
  • 2022-01-01
  • 2022-12-23
相关资源
相似解决方案