package try_catch;
import java.util.Scanner;
public class TryCatchPractice2 {
//在類開始聲明,則其他方法都能調用
Scanner in=new Scanner(System.in);
NoBookException NoB=new NoBookException();
String[] books={"語文","數學","英語"};
static TryCatchPractice2 trycat=new TryCatchPractice2();
//主函數
public static void main(String[]args) throws Exception{trycat.InputClassException();
}
//命令錯誤
public void InputClassException()throws Exception{
try{
System.out.println("歡迎光臨本圖書管理系統");
System.out.println("1.書名查詢。2.序號查詢");
int a=in.nextInt();
switch(a){
case 1://查找圖書
trycat.findBooks();
break;
case 2://查找序號
trycat.findBooksNum();
break;
default:
throw new NoBookException("錯誤命令,請輸入整數1