Delete Function:
private void xoaNhanVien() {
if (listNVs.size() < 1) {
System.out.println("Danh sach rong!");
return;
}
boolean tf;
int index = this.indexByName();
if (index >= 0 && index < listNVs.size()) {
do {
System.out.print("Ban co muon xoa khong (y/n) >");
String yn = sc.nextLine();
if (yn.trim().equalsIgnoreCase("y"))
if (this.xoa(index)) {
System.out.println("Xoa thanh cong!");
tf = true;
} else {
System.out.println("Xoa that bai!");
tf = true;
}
else if (yn.trim().equalsIgnoreCase("n"))
tf = true;
else
tf = false;
} while (tf != true);
} else
System.out.println("Khong tim thay nhan vien nay!!");
}
Sort Function
private void sapXepNhanVien() {
if (listNVs.size() < 1) {
System.out.println("Danh sach rong!");
return;
}
int index = this.indexByName();
for (int i = 0; i < listNVs.size() - 1; i++) {
for (int j = i + 1; j < listNVs.size(); j++) {
if (listNVs.get(i).getTen().compareTo(listNVs.get(j).getTen()) > 0) {
Collections.swap(listNVs, i, j);
}
}
}
listNVs.forEach(() -> {
System.out.println(.toString());
});
}