compass如何实现对对象的增删改查操作 设置高亮器 索引分页
编写要索引的类
Book
seacher
该程序是模拟数据库的操作
测试结果如下
== Select ==
1. List all books
2. Add new book
3. Delete book
4. Search book
5. Exit
1
========
== Database ==
1 | [id:9db5641b-957d-436e-94a1-5b4d7faaf028 title:Thinking in java author:Bruce price:10.9]
2 | [id:852ff241-62ee-4d94-9604-12b7db390edb title:Effective java author:Joshua price:10.9]
3 | [id:3979a6aa-68b2-4668-b4c0-551799e1806b title:Java Thread Programming author:Paul price:10.9]
---------
== Select ==
1. List all books
2. Add new book
3. Delete book
4. Search book
5. Exit
2
Title:
java
Author:
wuzhaohui
Price:
100.0
== Select ==
1. List all books
2. Add new book
3. Delete book
4. Search book
5. Exit
1
========
== Database ==
1 | [id:9db5641b-957d-436e-94a1-5b4d7faaf028 title:Thinking in java author:Bruce price:10.9]
2 | [id:852ff241-62ee-4d94-9604-12b7db390edb title:Effective java author:Joshua price:10.9]
3 | [id:3979a6aa-68b2-4668-b4c0-551799e1806b title:Java Thread Programming author:Paul price:10.9]
4 | [id:ae3c2b3e-2d66-4c4a-8e59-7758071e7a2c title:java author:wuzhaohui price:100.0]
---------
== Select ==
1. List all books
2. Add new book
3. Delete book
4. Search book
5. Exit
3
== Database ==
1 | [id:9db5641b-957d-436e-94a1-5b4d7faaf028 title:Thinking in java author:Bruce price:10.9]
2 | [id:852ff241-62ee-4d94-9604-12b7db390edb title:Effective java author:Joshua price:10.9]
3 | [id:3979a6aa-68b2-4668-b4c0-551799e1806b title:Java Thread Programming author:Paul price:10.9]
4 | [id:ae3c2b3e-2d66-4c4a-8e59-7758071e7a2c title:java author:wuzhaohui price:100.0]
Book index :
4
== Select ==
1. List all books
2. Add new book
3. Delete book
4. Search book
5. Exit
1
========
== Database ==
1 | [id:9db5641b-957d-436e-94a1-5b4d7faaf028 title:Thinking in java author:Bruce price:10.9]
2 | [id:852ff241-62ee-4d94-9604-12b7db390edb title:Effective java author:Joshua price:10.9]
3 | [id:3979a6aa-68b2-4668-b4c0-551799e1806b title:Java Thread Programming author:Paul price:10.9]
---------
== Select ==
1. List all books
2. Add new book
3. Delete book
4. Search book
5. Exit
4
Enter keywords:
java
== search results: 10 ==
[id:d954cce3-dd51-44b0-90a1-3363239d9559 title:Thinking in <font color='red'>java</font> author:Bruce price:0.0]
[id:903b8b04-d57a-4203-8464-f008bb8c3896 title:Effective <font color='red'>java</font> author:Joshua price:0.0]
[id:e82301b5-1583-478d-893f-5b8b078364a5 title:<font color='red'>Java</font> Thread Programming author:Paul price:0.0]
[id:9db5641b-957d-436e-94a1-5b4d7faaf028 title:Thinking in <font color='red'>java</font> author:Bruce price:0.0]
[id:852ff241-62ee-4d94-9604-12b7db390edb title:Effective <font color='red'>java</font> author:Joshua price:0.0]
[id:3979a6aa-68b2-4668-b4c0-551799e1806b title:<font color='red'>Java</font> Thread Programming author:Paul price:0.0]
[id:6ee2c10e-dde0-448b-8ca9-9e66cdeedc14 title:Thinking in <font color='red'>java</font> author:Bruce price:0.0]
[id:25e861b1-eff5-4eb9-8d5e-191131e968e8 title:Effective <font color='red'>java</font> author:Joshua price:0.0]
[id:6ec4f321-67b2-460b-b416-eb9d2cecae6d title:Thinking in <font color='red'>java</font> author:Bruce price:0.0]
[id:0d5ebf4a-0ef6-4475-9872-db9015637381 title:Effective <font color='red'>java</font> author:Joshua price:0.0]
== Select ==
1. List all books
2. Add new book
3. Delete book
4. Search book
5. Exit
3
== Database ==
1 | [id:9db5641b-957d-436e-94a1-5b4d7faaf028 title:Thinking in java author:Bruce price:10.9]
2 | [id:852ff241-62ee-4d94-9604-12b7db390edb title:Effective java author:Joshua price:10.9]
3 | [id:3979a6aa-68b2-4668-b4c0-551799e1806b title:Java Thread Programming author:Paul price:10.9]
Book index :
3
== Select ==
1. List all books
2. Add new book
3. Delete book
4. Search book
5. Exit
1
========
== Database ==
1 | [id:9db5641b-957d-436e-94a1-5b4d7faaf028 title:Thinking in java author:Bruce price:10.9]
2 | [id:852ff241-62ee-4d94-9604-12b7db390edb title:Effective java author:Joshua price:10.9]
---------
== Select ==
1. List all books
2. Add new book
3. Delete book
4. Search book
5. Exit