📄 test.java
字号:
package structs;
public class Test{
static Struct university;
static Libarary liba;
static Libarary libb;
static BookShelf shelfa;
static BookShelf shelfb;
static BookShelf shelfc;
static BookShelf shelfd;
static Book[] books;
static String[] keys;
static String keys2;
public static void display(){
liba.preDisplay("o---");
libb.display("o---");
}
public static void seekers(){
String target="compute public hello";
Book[] reg=new Book[3];
//通过搜索得到实例
//boolean t=books[0].hasKWS("computer");
reg[0]=liba.skByKW("computer");//通过关键字搜索
reg[1]=(Book)shelfa.skByName(books[3].Name);//通过名称搜索
reg[2]=libb.skByKW("Math");
//boolean[] record=book.compareTo(target);
for(int i=0;i<3;i++){
if(reg[i]!=null)
System.out.println("Found Name:"+reg[i].Name);
else
System.out.println("The "+i+"st NotFound!");
}
System.out.println("URL "+liba.find(books[0]));//通过实例搜索得到路径
}
public static void add(){
university.add(liba);
//university.add(libb);
Book book=new Book("testBook","Science");
BookShelf shelf=new BookShelf("TestShelf");
Page[] ps=new Page[]{
new Page("page1"),new Page("page2"),new Page("page3"),
new Page("page4"),new Page("page5"),new Page("page6")
};
books[0].addSubs(ps);//为第一本书加6页
//liba.add(shelf);//为图书室a加一个书架
// liba.add(book);//为图书室加一本书
liba.add("libB.shelfC",book);//通过路径加书
//libb.add("libB.shelfC",book);
university.preDisplay("o---");
//libb.preDisplay("o---");
}
public static void del(){
liba.display("o---");
liba.del(libb); //图书
liba.del(books[0]);
liba.del(shelfb);
liba.display("o---");
}
public static void main(String[] args){
init();
display();
//seekers();
// add();
// del();
}
public static void init(){
university=new Struct("NCEPU");
liba=new Libarary("libA");
libb=new Libarary("libB");
shelfa=new BookShelf("shelfA","Math");
shelfb=new BookShelf("shelfB","Computer");
shelfc=new BookShelf("shelfC","Science");
shelfd=new BookShelf("shelfD","Literature");
keys=new String[]{"computer","public","hello"};
keys2="computer public hello";
books=new Book[]{
new Book("booka","computer"),new Book("bookb","Literature"),
new Book("bookc","Computer"),new Book("bookd","Math"),
new Book("booke","Computer"),new Book("bookf","Literature"),
new Book("bookg","Computer"),new Book("bookh","Science")
};
liba.add(libb);
liba.add(shelfa);
liba.add(shelfb);
libb.add(shelfc);
libb.add(shelfd);
libb.add(shelfa);
for(int i=0;i<4;i++){
liba.add(books[i]);
libb.add(books[i+4]);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -