```
给予图书属性
```
package com;
public class leiXing {
public String name;
public int num;
public String date ;
public void print(int index){
System.out.println( index +"\t"+num+"\t"+name+"\t"+date);
}
}
```
给予图书储存空间
```
package com;
public class chuShiHua {
leiXing[] leiXings = new leiXing[50] ;
}
···
实现图书管理系统功能
```
package com;
import java.util.Scanner;
public class shangPingChu {
chuShiHua chuShiHuas =new chuShiHua() ;
Scanner scanner = new Scanner(System.in) ;
public void initial(){
leiXing shu1=new leiXing();
shu1.num =1;
shu1.name ="哈哈哈" ;
shu1.date ="07-18" ;
leiXing shu2 =new leiXing() ;
shu2.num =2;
shu2.name ="呼呼" ;
shu2 .date ="09-12" ;
leiXing shu3 =new leiXing() ;
shu3.num = 3;
shu3.name ="嘿嘿" ;
shu3.date ="06-25" ;
}
public void starMenu(){
boolean flag ;
do {
System.out.println("欢迎使用图书管理系统");
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("-----------------------");
System.out.println("请选择要执行的操作");
int choice =scanner.nextInt();
switch (choice){
case 1:
System.out.println("查看图书信息");
break;
case 2:
System.out.println("新增图书信息");
break;
case 3:
System.out.println("删除图书信息");
break;
case 4:
System.out.println("图书销售排行榜");
break;
case 5:
System.out.println("推出");
flag = false;
break;
default:
System.out.println("输入不符合要求");
}
flag = true ;
}while (flag) ;
}
public void search(){
System.out.println("编号\t书名\t借出日期");
for (int i = 0; i <chuShiHuas.leiXings.length ; i++) {
if (chuShiHuas.leiXings[i]!= null){
chuShiHuas.leiXings[i].print(i+1);
}
}
}public void add(){
Scanner scanner = new Scanner(System.in);
System.out.println("请输入书名");
String name =scanner.next();
System.out.println("请输入编号");
String num = scanner.next();
leiXing haha =new leiXing();
haha.name =name;
haha.num =0 ;
for (int i = 0; i <chuShiHuas.leiXings.length ; i++) {
if (chuShiHuas.leiXings[i] ==null){
chuShiHuas.leiXings[i] =haha ;
break;
}
}
}
}
```