package com.company;
import java.util.Scanner;
public class MiNiBookMgrSys1 {
? ? public static void main(String[] args) {
? ? ? ? Scanner sc = new Scanner(System.in);
? ? ? ? //初始化書本信息
? ? ? ? String[] bookNames = new String[6];
? ? ? ? int[] borrowDates = new int[6];
? ? ? ? int[] borrowCounts = new int[6];
? ? ? ? int[] states = new int[6];
? ? ? ? //初始化三本書
? ? ? ? bookNames[0] = "安徒生童話";
? ? ? ? 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開發(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圖書管理系統(tǒng)**********");
? ? ? ? ? ? System.out.println("\t\t\t\t\t1.新增圖書");
? ? ? ? ? ? System.out.println("\t\t\t\t\t2.查看圖書");
? ? ? ? ? ? System.out.println("\t\t\t\t\t3.借閱圖書");
? ? ? ? ? ? System.out.println("\t\t\t\t\t4.歸還圖書");
? ? ? ? ? ? System.out.println("\t\t\t\t\t5.刪除圖書");
? ? ? ? ? ? System.out.println("\t\t\t\t\t6.退出系統(tǒng)");
? ? ? ? ? ? System.out.print("\n請選擇:");
? ? ? ? ? ? int choose = sc.nextInt();
? ? ? ? ? ? while(choose<0 || choose>6){
? ? ? ? ? ? ? ? System.out.print("輸入有誤,重新輸入:");
? ? ? ? ? ? ? ? choose = sc.nextInt();
? ? ? ? ? ? }
? ? ? ? ? ? switch(choose){
? ? ? ? ? ? ? ? case 1:
? ? ? ? ? ? ? ? ? ? System.out.println("************1.新增圖書**********");
? ? ? ? ? ? ? ? ? ? System.out.print("請輸入新增圖書的名字:");
? ? ? ? ? ? ? ? ? ? String addBook = sc.next();
? ? ? ? ? ? ? ? ? ? boolean isAdd = false;//false:不能添加圖書? true:可以添加圖書
? ? ? ? ? ? ? ? ? ? //遍歷數(shù)組,查找新增圖書的位置
? ? ? ? ? ? ? ? ? ? for(int i =1;i<bookNames.length;i++){
? ? ? ? ? ? ? ? ? ? ? ? //數(shù)組沒滿粒蜈,可以新增圖書
? ? ? ? ? ? ? ? ? ? ? ? if(bookNames[i] == null){
? ? ? ? ? ? ? ? ? ? ? ? ? ? isAdd = true;
? ? ? ? ? ? ? ? ? ? ? ? ? ? bookNames[i] = addBook;