public void test2(){
Scanner input=new Scanner(System.in);
System.out.println("输入命令:1-按照图书名称查询;2-按照图书序号查询");
try{
int a=input.nextInt();
test1(a);
}catch(Exception e){
System.out.println("请正确输入:");
test2();
}
}
public void test1(int b){
Scanner input=new Scanner(System.in);
if(b==1){
System.out.println("输入图书的名称:");
String name=input.next();
if(name.equals("高数")||name.equals("英语")||name.equals("语文")){
System.out.println("book:"+name);
}else{
System.out.println("图书不存在!");
test2();
}
}
else{
System.out.println("输入图书的序号:");
int cc=input.nextInt();
String sm[]={"语文","数学","英语","政治","健康","财经","日语"};
if(cc<sm.length){
System.out.println("book:"+sm[cc]);
}else{
System.out.println("图书不存在!");
test2();
}
}
}
public static void main(String[] args) {
Initial hobby=new Initial();
hobby.test2();
}
热门评论
用java能实现借书系统,神奇