public static void main(String[] args) {
ArrayList<Book> lists = new ArrayList<>();
lists.add(new Book(1, "西游记", "吴承恩", 20.0d));
lists.add(new Book(2, "水浒传", "施耐庵", 40.0d));
lists.add(new Book(3, "武庚纪", "张三", 60.0d));
lists.add(new Book(4, "三国演义", "李四", 30.0d));
lists.add(new Book(5, "红楼梦", "王五", 50.0d));
lists.add(new Book(6, "斗破苍穹", "赵六", 20.0d));
lists.add(new Book(7, "斗罗大陆", "宋七", 90.0d));
System.out.println("图书加载完毕.............");
Scanner sc = new Scanner(System.in);
System.out.print("请输入书名:");
String s = sc.nextLine();
String bookname = "";
for (Book list : lists) {
bookname = list.getBookname();
if (bookname.contains(s)){
System.out.println("您查询的信息为:"+"id:"+list.getId()+"书名:"+list.getBookname()+"作者:"+list.getAuthor()+"价格:"+list.getPrice());
}
}
if (!bookname.contains(s)){
System.out.println("您查询的信息不存在......");
}
System.out.println("查询完毕.......................");
}