package test3;
import java.util.Scanner;
public class M2 {
public static void main(String[] args) {
System.out.println("***欢迎来到图书馆系统***");
System.out.println("输入命令:1.按照名称查找图书;2.按照序号查找图书");
Scanner input=new Scanner(System.in);
M2 clc=new M2();
try{int a=input.nextInt();
if(a==1){System.out.println("输入图书名称:");
String b=input.next();
clc.book(b);
}
else if(a==2){
System.out.println("输入图书序号:");
int c=input.nextInt();
clc.book2(c);
}
}catch(Exception e){
e.printStackTrace();
System.out.println("命令输入错误!请根据提示输入数字命令!");
}
} String name;
public void book(String name) throws Exception{
this.name=name;
if(name.equals("高数")){System.out.println("book:"+name);}
else if(name.equals("数据结构")){System.out.println("book:"+name);
}else{throw new Exception("图书不存在!");}
}int num=0;
public void book2(int num) throws Exception{
this.num=num;
if(num==1){System.out.println("book:高数");}
else if(num==2){System.out.println("book:数据结构");}
else{throw new Exception("图书不存在!");}
}
}