em đang làm từ điển mini và phải dùng linklist.chương trình chạy được vài cái hàm add xong chạy lookup với các cái khác đều không được là sao ạ???
mọi người giúp em với
đây là code của class dictionary, còn file main em đính kèm rồi ạ,
đề đây nữa ạ

Từ điển nạp dữ liệu từ file có tên DICT.DAT (charsetName="Unicode" - mã Unicode) với định dạng như sau: Mỗi mục từ nằm trên 1 dòng với cú pháp:

<word>:<space><meanings>
trong đó, <word> là một chuỗi kí tự không chứa dấu hai chấm ":"; <space> chỉ bao gồm đúng 01 kí tự space; <meanings> là chuỗi kí tự kéo dài cho đến hết dòng.
Người dùng đảm bảo sự tồn tại của file dữ liệu nằm tại thư mục nơi chạy chương trình, dữ liệu trong file là hợp lệ. Tuy nhiên, các mục từ trong file không được xếp theo thứ tự từ điển, không có giới hạn về số mục từ.
Từ điển cần đáp ứng các lệnh sau do người dùng gõ vào tại dấu nhắc:
Lệnh Công việc chương trình cần thực hiện
save
lưu nội dung từ điển ra tệp DICT.DAT theo thứ tự từ điển, với định dạng như đã quy định
add<space><word>:<space><meanings>
Nếu trong từ điển đã có mục từ dành <word> thì nối thêm "; "<meanings> vào đuôi của meanings sẵn có trong mục từ đó. Nếu chưa có thì bổ sung mục từ mới.
lookup<space><word>
tìm <word> trong từ điển. Nếu tìm thấy thì in meaning trên một dòng (không được thừa hay thiếu dấu cách). Nếu không thì in ra thông báo "Not found." trên một dòng
delete<space><word>
xóa mục từ <word> trong từ điển. Nếu tìm thấy và xóa thì in thông báo "<word> deleted." trên một dòng (không được thừa hay thiếu dấu cách). Nếu không thì in ra thông báo "Not found." trên một dòng.
quit
ngừng chương trình

import java.util.Scanner;
import java.nio.file.Files;
import java.util.List;
import java.io.*;

class Dictionary
{
public static Scanner in = new Scanner(System.in);
private Node head;

//constructor
public Dictionary(){};

public Dictionary(String en, String vi){
head = new Node(en, vi); //khoi tao con tro head moi
}

//functions
//Node tro den cac tu tieng anh trong danh sach
public Node lookup(String en){
Node temp = head;
if(head == null)
return null;
while(temp != null){
if(temp.getEn().equals(en))
return temp;
temp = temp.next;
}
return null;
}

//ham kiem tra 1 tu tieng viet co trong danh sach nghia cac tu trong tu dien khong
public boolean check(String s, Node node){
String s1 = node.getVi();
//tach nghia ra thanh tung tu neu nghia cua tu co 2 tu tro len
for(String mid : s1.split("[:]")){
if(s.equalsIgnoreCase(mid.trim())) return true;
}
return false;
}

//ham kiem tra tu tieng viet ung voi tu tieng anh dang tim kiem
public boolean lookupVi(String word){
word = word.trim();
if(lookup(word) == null)
return false;
else return true;
}

//ham tra ve tu tieng anh ung voi nghia tieng viet da nhap vao
public boolean lookupEn(String vi){
vi = vi.trim(); //bo khoang trang dau va cuoi tu
Node temp = head;
if(head == null) return false;
while(temp != null){
if(check(vi, temp))
return true;
}
return false;
}

//ham tim kiem xem tu do co trong tu dien khong, neu co thi in ra nghia
public String search(){
String word = in.nextLine();
word = word.trim();
Node temp = head;
if(head == null) return "Not found.";
while(temp != null){
//kiem tra xem co phai la tu tieng anh khong, neu phai thi in ra nghia tieng viet
if(temp.getEn().equalsIgnoreCase(word)){
if(lookupEn(word))
return temp.getEn();
else return "Not found.";
}

//kiem tra xem co phai la tu tieng viet khong, neu phai thi in ra nghia tieng anh
else if(temp.getVi().equalsIgnoreCase(word)){
if(lookupVi(word))
return temp.getVi();
else return "Not found.";
}
temp = temp.next;
}
return "Not found.";
}

//ham them tu vao tu dien
public void add(String s1, String s2){
Node node = lookup(s1);
if(node != null){
node.setVi(node.getVi() + "; " +s2);
}

else{
Node temp = new Node(s1, s2);
if(head == null) head = temp;
else{
temp.next = head;
head = temp;
}
}
}

//tra ve lien ket truoc node
public Node before(Node node){
Node temp = head;
if(node == null || head == null || node == head)
return node = null;
while(temp.next != node)
{
temp = temp.next;
}
return temp;
}

//tra ve nut cuoi cung trong lien ket
public Node last(){
Node temp;
temp = head;
if(head == null) return null;
while(temp.next != null){
temp = temp.next;
}
return temp;
}

//ham xoa tu
public void delete(){
String word = in.nextLine();
word = word.trim(); //loai bo khoang trang dau va cuoi cua tu
Node temp = lookup(word);
if(temp == null)
System.out.println("Not found.");
else{
if(temp == head)
head = head.next;
else{
Node temp1 = before(temp);
temp1.next = temp.next;
}
if(word == temp.getEn()){
System.out.print(temp.getVi() + " deleted.");
}
else if(word == temp.getVi()){
System.out.print(temp.getVi() + " deleted.");
}

}
}

//ham thay the gia tri cua node
public void thaythe(Node node, String en, String vi){
node.setEn(en);
node.setVi(vi);
}

//ham trao doi du lieu cua 2 node
public void Swap(Node node1, Node node2){
Node node = new Node(node1.getEn(), node2.getVi());
thaythe(node1, node2.getEn(), node2.getVi());
thaythe(node2, node.getEn(), node.getVi());
}

//ham sap xep node theo thu tu tu dien
public void sort(){
Node temp1, temp2;
temp1 = head;
if(head == null) return;
while(temp1 != null){
temp2 = temp1;
while(temp2 != null){
if(temp1.getEn().compareTo(temp2.getEn()) > 0 || (temp1.getEn().compareTo(temp2.getEn()) == 0 && temp1.getVi().compareTo(temp2.getVi()) > 0)){
Swap(temp1, temp2);
}
}
temp1 = temp1.next;
}
}

//ham luu danh sach vao file
public void save(){
sort();
try{
FileWriter writer = new FileWriter("DICH.DAT");
Node temp = head;
while(temp != null)
{
writer.write(temp.toString() + "
");
temp = temp.next;
}
writer.close();
}
catch(IOException e){
e.printStackTrace();
}
}
public Node getHead(){
return head;
}
}