第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

交作業(yè)---模擬結(jié)束系統(tǒng)

public?class?BorrowBook?{
????public?static?String[]?books?=?{"第一行代碼",?"thinking?in?java",?"安卓探索藝術(shù)"};
????public?static?Scanner?sc;
????public?static?boolean?flag?=?true;
????public?static?boolean?isIndexOrName?=?false;

????public?static?void?main(String[]?args)?{
????????System.out.println("***歡迎來(lái)到模擬圖書(shū)系統(tǒng)***");
????????System.out.println("請(qǐng)輸入您要查找圖書(shū)的方式:1.按圖書(shū)序號(hào)查找"?+?"\t"?+?"2.按圖書(shū)名稱(chēng)查找");
????????System.out.println("請(qǐng)輸入一個(gè)有效查找方式:");
????????find2IndexOrName();
????}

????private?static?void?find2IndexOrName()?{
????????sc?=?new?Scanner(System.in);
????????int?input?=?sc.nextInt();
????????try?{
????????????if?(1?==?input)?{
????????????????System.out.println("請(qǐng)輸入有效圖書(shū)序號(hào):");
????????????????int?index?=?sc.nextInt();
????????????????find2Index(index);
????????????}?else?if?(2?==?input)?{
????????????????System.out.println("請(qǐng)輸入正確的書(shū)名:");
????????????????String?name?=?sc.next();
????????????????find2Name(name);
????????????}?else?{
????????????????throw?new?Exception();
????????????}
????????}?catch?(Exception?e)?{
????????????System.out.println("請(qǐng)輸入正確指令:");
????????????find2IndexOrName();
????????}
????}

????public?static?void?find2Name(String?name)?{
????????isIndexOrName?=?true;
????????try?{
????????????for?(int?i?=?0;?i?<?books.length;?i++)?{
????????????????if?(name.equals(books[i]))?{
????????????????????showBook(name,?i);
????????????????????break;
????????????????}?else?{
????????????????????throw?new?Exception();
????????????????}
????????????}
????????}?catch?(Exception?e)?{
????????????System.out.println("圖書(shū)不存在,請(qǐng)重新輸入:");
????????????String?s?=?sc.next();
????????????find2Name(s);
????????}
????}

????public?static?void?find2Index(int?index)?{
????????isIndexOrName?=?false;
????????try?{
????????????for?(int?i?=?0;?i?<?books.length;?i++)?{
????????????????if?(index?==?i)?{
????????????????????showBook(index);
????????????????????break;
????????????????}?else?if?(index?>?2)?{
????????????????????throw?new?Exception();
????????????????}
????????????}
????????}?catch?(Exception?e)?{
????????????System.out.println("圖書(shū)不存在,請(qǐng)重新輸入:");
????????????int?i?=?sc.nextInt();
????????????find2Index(i);
????????}
????}

????/**
?????*?通過(guò)書(shū)名查找圖書(shū)
?????*
?????*?@param?name??書(shū)名
?????*?@param?index?書(shū)名對(duì)應(yīng)的下標(biāo)
?????*/
????private?static?void?showBook(String?name,?int?index)?{
????????System.out.println("***查找到以下內(nèi)容***");
????????if?(books[index].equals(name))?{
????????????System.out.println("第一行代碼");
????????}?else?if?(books[index].equals(name))?{
????????????System.out.println("thinking?in?java");
????????}?else?if?(books[index].equals(name))?{
????????????System.out.println("安卓探索藝術(shù)");
????????}
????????System.out.println("***確定借閱嗎?(Y/N)***");
????????String?s?=?sc.next();
????????isBorrow(s);
????}

????/**
?????*?通過(guò)圖書(shū)序號(hào)查找
?????*
?????*?@param?index?圖書(shū)的序號(hào)
?????*/
????private?static?void?showBook(int?index)?{
????????System.out.println("***查找到以下內(nèi)容***");
????????System.out.println(books[index]);
????????System.out.println("確認(rèn)借閱本書(shū)嗎?(Y/N)");
????????String?s?=?sc.next();
????????isBorrow(s);
????}

????private?static?void?isBorrow(String?s)?{
????????if?(s.equals("Y")?||?s.equals("y"))?{
????????????System.out.println("恭喜您借閱成功");
????????}?else?if?(s.equals("N")?||?s.equals("n"))?{
????????????System.out.println("您以取消操作!請(qǐng)重新操作!");
????????????if?(flag)?{
????????????????System.out.println("請(qǐng)輸入一個(gè)有效查找方式:"+"\n"+"1.按序號(hào)查找"+"\n"+"2.按書(shū)名查找");
????????????????find2IndexOrName();
????????????}
????????}
????}
}


正在回答

1 回答

都沒(méi)有用到多重catch

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

慕標(biāo)5588573 提問(wèn)者

你把簡(jiǎn)單的問(wèn)題復(fù)雜化了,這并不符合面向?qū)ο蟮木幊趟枷?/div>
2019-02-25 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

交作業(yè)---模擬結(jié)束系統(tǒng)

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)