-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDictionaryCommandline.java
More file actions
52 lines (46 loc) · 1.63 KB
/
Copy pathDictionaryCommandline.java
File metadata and controls
52 lines (46 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import java.util.Scanner;
public class DictionaryCommandline {
DictionaryManagement dictManage = new DictionaryManagement();
private final int spaceNoEng = 9;
private final int spaceEngViet = 28;
public Scanner sc = new Scanner(System.in);
private void createOutput(int no, String target, String explain) {
if (no == 0) {
System.out.println("No | English | Vietnamese");
return;
}
System.out.print(no);
for (int i = 0; i < spaceNoEng - String.valueOf(no).length(); i++) {
System.out.print(" ");
}
System.out.print("| ");
System.out.print(target);
for (int i = 0; i < spaceEngViet - target.length(); i++) {
System.out.print(" ");
}
System.out.print("| ");
System.out.println(explain);
}
public void showAllWords() {
System.out.println("Welcome to ViEnDictionary!!\n");
for (int i = -1; i < dictManage.dict.wordsList.size(); i++) {
if (i != -1) {
String newWord = dictManage.dict.vocabList.get(i);
String newMeaning = dictManage.dict.wordsList.get(i).getWordExplain();
createOutput(i + 1, newWord, newMeaning);
}
else {
createOutput(i + 1, "", "");
}
}
}
public void dictionaryAdvanced() {
dictManage.insertFromFile();
showAllWords();
dictManage.dictionaryLookup();
}
public void dictionarySearcher() {
String pattern = sc.nextLine();
dictManage.tree.autoComplete(pattern);
}
}