bool CoChua(ThueBao tb) { for (int i = 0; i < length; i++) { if (a[i].soCMND == tb.soCMND) { return(true); } } return(false); }
public void SapXep(KieuSapXep k) { for (int i = 0; i < length - 1; i++) { for (int j = i + 1; j < length; j++) { if (KiemTraDieuKien(a[i], a[j], k) == 1) { ThueBao tam = a[i]; a[i] = a[j]; a[j] = tam; } } } }
private int KiemTraDieuKien(ThueBao thueBao1, ThueBao thueBao2, KieuSapXep k) { if (k == KieuSapXep.TangTheoHoTen) { return(thueBao1.hoTen.CompareTo(thueBao2.hoTen)); } if (k == KieuSapXep.GiamTheoHoTen) { return(-thueBao1.hoTen.CompareTo(thueBao2.hoTen)); } if (k == KieuSapXep.TangTheoNgaySinh) { return(thueBao1.ngaySinh.CompareTo(thueBao2.ngaySinh)); } if (k == KieuSapXep.GiamTheoNgaySinh) { return(-thueBao1.ngaySinh.CompareTo(thueBao2.ngaySinh)); } return(-1); }
public void Them(ThueBao tb) { a[length++] = tb; }
public void Them_TB(ThueBao x) { DS_TB.Add(x); }