Chuyển từ chức năng xóa sang chức năng sắp xếp tăng dần, giảm dần với cấu trúc tương tự thì làm sao mọi người?
private ArrayList<ThongTinCoBan> listNVs;
private Scanner sc;
public boolean xoa(int index){
if(listNVs.remove(index) != null)
return true;
else
return false;
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!!");
}