2021-04-11

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);

? ? }

}

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容