📄 search.java
字号:
import java.io.*;
import java.util.*;
public class Search {
//The data field
private String[] relatedWords;
private String possibleWord;
private int wordIndex;
private int possibleWordIndex;
//the constructor
public Search(){
}
//judge if it is null
public boolean isNull(String wordSearch){
if(wordSearch.equals(""))
return true;
else
return false;
}
//the method that find if the lib have the word user search
public boolean haveTheWord(String wordSearch,String[] libString){
boolean judge=false;
for(int j=0;j<libString.length;j++){
if(wordSearch.equals(libString[j])){
judge=true;
}
}
return judge;
}
//get the wordIndex from the libString
public int getWordIndex(String wordSearch,String[] libString){
for(int k=0;k<libString.length;k++){
if(wordSearch.equals(libString[k])){
wordIndex=k;
break;
}
}
return wordIndex;
}
//get possible word by the swap method
//public int getPossibleWordBySwap(String wordSearch,String[] libString){
//}
//get related word
public int[] getRelateWord(String wordSearch,String[] libString){
int relatedWordIndex=0; //the index next to the word rearched;
int[] relatedWords=new int[50];
relatedWordIndex=getWordIndex(wordSearch, libString);
for(int i=0;i<50;i++){
relatedWords[i]=relatedWordIndex+i*2;
}
return relatedWords;
}
//get poosible word by binary search
public int getPossibleWord(String wordSearch,String[] libString){
for(int p=0;p<libString.length;p=p+2){
if(wordSearch.compareToIgnoreCase(libString[p])<0){
wordIndex=p;
break;
}
}
return wordIndex;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -