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

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

根據(jù)大佬代碼進(jìn)行了小小修改,希望對各位有所幫助,有錯誤也請指正。

package?borrow_books;

import?java.util.InputMismatchException;
import?java.util.Scanner;

public?class?Test?{
????int?command;
????Scanner?input?=?new?Scanner(System.in);
????String?book[]?=?{"高數(shù)",?"數(shù)據(jù)結(jié)構(gòu)"};

????public?static?void?main(String[]?args)?{
????????while?(true){Test?test=new?Test();
????????test.inputCommend();
????????if(test.command==1){
????????????test.inputName();
????????}else?if(test.command==2){
????????????test.inputNumber();
????????}else?if?(test.command==3){
????????????System.out.println("退出程序");
????????????break;
????????}
????}}
????public?class?ErrorFanhuiException?extends?Exception{
????????public?ErrorFanhuiException(){
????????????super("輸入錯誤,請輸入數(shù)字命令");
????????}
????}
????public?class?BooknotExistException?extends?Exception{
????????public?BooknotExistException(){
????????????super("圖書不存在");
????????}
????}
????public?void?inputCommend(){
????????try?{
????????????System.out.println("輸入命令:1-按名稱查找圖書?2-按數(shù)字查找圖書?3-退出");
????????????command=input.nextInt();
????????????if((command!=1)&&(command!=2)&&(command!=3)){
????????????????throw?new?ErrorFanhuiException();
????????????}
????????}catch?(InputMismatchException?ie){
????????????ErrorFanhuiException?ee=new?ErrorFanhuiException();
????????????System.out.println(ee.getMessage());
????????}catch?(ErrorFanhuiException?ee){
????????????System.out.println(ee.getMessage());
????????}
????}
????public?void?inputName(){
????????try?{
????????????System.out.print("輸入圖書名稱:");
????????????String?a2=input.next();
????????????for(int?i=0;i<?book.length;i++){
????????????????if(book[i].equals(a2)){
????????????????????System.out.println("book:"+book[i]);
????????????????????return;
????????????????}
????????????}
????????????throw?new?BooknotExistException();
????????}catch?(Exception?e){
????????????System.out.println(e.getMessage());
????????}


????}
????public?void?inputNumber(){
????????try?{
????????????System.out.print("輸入圖書序號:");
????????????int?a3=input.nextInt();
????????????for?(int?i=0;i<?book.length;i++){
????????????????if?(a3==i){
????????????????????System.out.println("book:"+book[i]);
????????????????????return;
????????????????}
????????????}
????????????throw?new?BooknotExistException();
????????}catch?(InputMismatchException?ie){
????????????input.nextLine();
????????????ErrorFanhuiException?ee=new?ErrorFanhuiException();
????????????System.out.println(ee.getMessage());
????????}catch?(BooknotExistException?be){
????????????System.out.println(be.getMessage());
????????????return;
????????}
????????}


}


正在回答

2 回答

好棒啊

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

很好很強(qiáng)大

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

舉報(bào)

0/150
提交
取消

根據(jù)大佬代碼進(jìn)行了小小修改,希望對各位有所幫助,有錯誤也請指正。

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

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

幫助反饋 APP下載

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

公眾號

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