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

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

設(shè)計了一個BOOK類,但是死活用不上--

import?java.util.ArrayList;
import?java.util.Arrays;
import?java.util.InputMismatchException;
import?java.util.Scanner;
public?class?TestBook?{
	static?ArrayList<String>?as=new?ArrayList<String>();
	public?static?void?main(String[]?args)?{
		//?TODO?Auto-generated?method?stub
		as.add("線性代數(shù)");
		as.add("高等數(shù)學(xué)");
		TestBook?s=new?TestBook();
		s.method3();
	}
	void?method3(){
		System.out.println("***輸入命令:1-按照名稱查找圖書;2-按照序號查找圖書");
		TestBook?s=new?TestBook();
		s.method1();
		s.method2();
	}
	void?method2(){
		Scanner?in=new?Scanner(System.in);
		try?{
			int?a=in.nextInt();
			try{
				System.out.println(a+"."+as.get(a));
			}catch(IndexOutOfBoundsException?s){
				System.out.println("沒有這本圖書!");
				method3();
			}
		}
		catch(InputMismatchException?s){
		String?a=in.next();
			if(as.contains(a)){

				System.out.println(as.indexOf(a)+a);
			}
			else{
				System.out.println("沒有這本圖書!");
				method3();
			}
		}
	}
	void?method1(){
		Scanner?in=new?Scanner(System.in);
		
		try{
			int?a=in.nextInt();
			
			if(a==2){
				System.out.println("請輸入圖書序號:");
			}
			else?if(a==1){
				System.out.println("請輸入圖書名稱:");
			}
			else{
				System.out.println("輸入有誤,請重新輸入!");
				method1();
			}
		}
		catch(InputMismatchException?s){
			System.out.println("輸入有誤,請重新輸入!");
			method1();
		}

	}

}


正在回答

1 回答

把Book類和Test類分開寫,main函數(shù)放在Test類里

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

舉報

0/150
提交
取消

設(shè)計了一個BOOK類,但是死活用不上--

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

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

幫助反饋 APP下載

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

公眾號

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