package 图书管理系统;
import java.util.Scanner;
public class JIAO {
xu yan = new xu();
Scanner scanner = new Scanner(System.in);
public void mi(){
zhao shu = new zhao();
shu.name = "java基础教程";
shu.kk = 0;
shu.shi = 2015-7-1;
zhao ju = new zhao();
ju.name = "数据库技术";
ju.kk = 1;
ju.shi = 0;
zhao ren = new zhao();
ren.shi = 0;
ren.name = "人月神话";
ren.kk = 1;
yan.yang[0] = shu;
yan.yang[1] = ju;
yan.yang[2] = ren;
}
public void yi(){
boolean flag = true;
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("6.退出");
System.out.println("请选择:");
int ll = scanner.nextByte();
switch (ll){
case 1:
System.out.println("查看图书");
cha();
break;
case 2:
System.out.println("新增图书");
ww();
break;
case 3:
System.out.println("删除图书");
bb();
break;
case 4:
System.out.println("借出图书");
jj();
break;
case 5:
System.out.println("归还图书");
aa();
break;
case 6:
System.out.println("谢谢使用");
flag = false;
break;
default:
System.out.println("输入不符合要求请重新输入!");
break;
}
}while (flag);
}
public static void main(String[] args) {
JIAO bo = new JIAO();
bo.mi();
bo.yi();
}
public void cha(){
System.out.println("编号\t书名\t借出\t日期");
for (int i = 0; i if (yan.yang[i]!=null){ yan.yang[i].pp(i+1); } } } public void ww(){ System.out.println("新增图书的书名;"); String name = scanner.next(); System.out.println("新增图书的借出:"); int kk = scanner.nextByte(); System.out.println("新增图书的日期:"); int shi = scanner.nextByte(); zhao uu = new zhao(); uu.shi = shi; uu.name = name; uu.kk = kk; for (int i = 0 ;i < yan.yang.length;i++){ if (yan.yang[i]==null){ yan.yang[i]=uu; break; } } } public void bb(){ System.out.println("请输入书籍编号:"); boolean flag = true; int cc = scanner.nextByte(); for (int i = 0; i if (yan.yang[i]!=null&&(i+1)==cc){ int j = i ; while (yan.yang[j+1]!=null){ yan.yang[j] = yan.yang[j+1]; j++; } yan.yang[j] = null; flag = true; break; }else { flag = false; } } if (flag){ System.out.println("删除成功"); }else { System.out.println("删除失败"); } } public void jj(){ System.out.println("请输入你要借走的书籍名字:"); String name = scanner.next(); boolean flag = true; for (int i= 0; i if (yan.yang[i]!=null&&yan.yang[i].name.equals(name)){ System.out.println("请输入你要借走几本:"); int ee = scanner.nextByte(); yan.yang[i].kk = yan.yang[i].kk - ee; flag = true; }else { System.out.println("商品数量不够抓紧进货!"); flag = false; } break; } if (flag){ System.out.println("售卖成功"); }else { System.out.println("售卖失败"); } } public void aa(){ System.out.println("归还图书的书名;"); String name = scanner.next(); System.out.println("归还图书的借出:"); int kk = scanner.nextByte(); System.out.println("归还图书的日期:"); int shi = scanner.nextByte(); zhao uu = new zhao(); uu.shi = shi; uu.name = name; uu.kk = kk; for (int i = 0 ;i < yan.yang.length;i++){ if (yan.yang[i]==null){ yan.yang[i]=uu; break; } } } }