import java.util.Scanner;
/**
* @author WangPenghui
* @date 2021/4/11 17:09
*/
public class tushuguanli {
? ? public static void main(String[] args) {
? ? ? ? Scanner sc = new Scanner(System.in);
? ? ? ? //初始化書(shū)本信息
? ? ? ? String[] bookNames = new String[6];
? ? ? ? int[] borrowDates = new int[6];
? ? ? ? int[] borrowCounts = new int[6];
? ? ? ? int[] states = new int[6];
? ? ? ? //初始化三本書(shū)
? ? ? ? bookNames[0] = "大學(xué)生安全教育";
? ? ? ? borrowDates[0] = 15;
? ? ? ? borrowCounts[0] = 16;
? ? ? ? states[0] = 0;//0:可借閱 1:已借出
? ? ? ? bookNames[1] = "老人與海";
? ? ? ? borrowDates[1] = 0;
? ? ? ? borrowCounts[1] = 0;
? ? ? ? states[1] = 1;//0:可借閱 1:已借出
? ? ? ? bookNames[2] = "Java程序開(kāi)發(fā)";
? ? ? ? borrowDates[2] = 0;
? ? ? ? borrowCounts[2] = 0;
? ? ? ? states[2] = 0;//0:可借閱 1:已借出
? ? ? ? int num = -1;//初始化用戶輸入的數(shù)字
? ? ? ? boolean flag = true;//true:不退出系統(tǒng) false:退出系統(tǒng)
? ? ? ? do {
? ? ? ? ? ? System.out.println("************歡迎使用MiNi圖書(shū)管理系統(tǒng)**********");
? ? ? ? ? ? System.out.println("\t\t\t\t\t1.新增圖書(shū)");
? ? ? ? ? ? System.out.println("\t\t\t\t\t2.查看圖書(shū)");
? ? ? ? ? ? System.out.println("\t\t\t\t\t3.借閱圖書(shū)");
? ? ? ? ? ? System.out.println("\t\t\t\t\t4.歸還圖書(shū)");
? ? ? ? ? ? System.out.println("\t\t\t\t\t5.刪除圖書(shū)");
? ? ? ? ? ? System.out.println("\t\t\t\t\t6.退出系統(tǒng)");
? ? ? ? ? ? System.out.print("\n請(qǐng)選擇:");
? ? ? ? ? ? int choose = sc.nextInt();
? ? ? ? ? ? while (choose < 0 || choose > 6) {
? ? ? ? ? ? ? ? System.out.print("輸入有誤,重新輸入:");
? ? ? ? ? ? ? ? choose = sc.nextInt();
? ? ? ? ? ? }
? ? ? ? ? ? switch (choose) {
? ? ? ? ? ? ? ? case 1:
? ? ? ? ? ? ? ? ? ? System.out.println("************1.新增圖書(shū)**********");
? ? ? ? ? ? ? ? ? ? System.out.print("請(qǐng)輸入新增圖書(shū)的名字:");
? ? ? ? ? ? ? ? ? ? String addBook = sc.next();
? ? ? ? ? ? ? ? ? ? boolean isAdd = false;//false:不能添加圖書(shū)? true:可以添加圖書(shū)
? ? ? ? ? ? ? ? ? ? //遍歷數(shù)組,查找新增圖書(shū)的位置
? ? ? ? ? ? ? ? ? ? for (int i = 1; i < bookNames.length; i++) {
? ? ? ? ? ? ? ? ? ? ? ? //數(shù)組沒(méi)滿,可以新增圖書(shū)
? ? ? ? ? ? ? ? ? ? ? ? if (bookNames[i] == null) {
? ? ? ? ? ? ? ? ? ? ? ? ? ? isAdd = true;
? ? ? ? ? ? ? ? ? ? ? ? ? ? bookNames[i] = addBook;
? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? }while(flag);
? ? }
}