public DanhSachHinhHoc Tim_DS_HT(DanhSachHinhHoc a) { DanhSachHinhHoc kq = new DanhSachHinhHoc(); foreach (var item in a.DS_HH) { if (item is HinhTron) { kq.Them(item); } } return(kq); }
public DanhSachHinhHoc Tim_DS_HV(DanhSachHinhHoc a) { DanhSachHinhHoc kq = new DanhSachHinhHoc(); foreach (var item in a.DSHinhHoc) { if (item is HinhVuong) { kq.Them(item); } } return(kq); }
public DanhSachHinhHoc Tim_Hinh_DT_Max(DanhSachHinhHoc a) { DanhSachHinhHoc DS = new DanhSachHinhHoc(); float max = a.TimMax_DT(); foreach (var item in a.DS_HH) { if (item.Tinh_DienTich() == max) { DS.Them(item); } } return(DS); }
public DanhSachHinhHoc TimHinhCoCVMax(DanhSachHinhHoc a) { DanhSachHinhHoc ds = new DanhSachHinhHoc(); float max = a.TimMax_CV(); foreach (var item in a.DSHinhHoc) { if (item.TinhChuVi() == max) { ds.Them(item); } } return(ds); }
public DanhSachHinhHoc Tim_Hinh_CV_Min(DanhSachHinhHoc a) { DanhSachHinhHoc DS = new DanhSachHinhHoc(); float min = a.TimMin_CV(); foreach (var item in a.DS_HH) { if (item.Tinh_ChuVi() == min) { DS.Them(item); } } return(DS); }
public DanhSachHinhHoc TimHinhCoDTMin(DanhSachHinhHoc a) { DanhSachHinhHoc ds = new DanhSachHinhHoc(); float min = a.TimMin_DT(); foreach (var item in a.DSHinhHoc) { if (item.TinhDienTich() == min) { ds.Them(item); } } return(ds); }
//Tim hcn dien tich nho nhat public DanhSachHinhHoc TimHCNDTMin(DanhSachHinhHoc a) { DanhSachHinhHoc ds = Tim_DS_HCN(a); DanhSachHinhHoc kq = new DanhSachHinhHoc(); float min = ds.TimMin_DT(); for (int i = 0; i < ds.Dai; i++) { if (ds[i].TinhDienTich() == min) { kq.Them(ds[i]); } } return(kq); }
//Tim hinh vuong dien tich max min public DanhSachHinhHoc TimHVDTMax(DanhSachHinhHoc a) { DanhSachHinhHoc ds = Tim_DS_HV(a); DanhSachHinhHoc kq = new DanhSachHinhHoc(); float max = ds.TimMax_DT(); for (int i = 0; i < ds.Dai; i++) { if (ds[i].TinhDienTich() == max) { kq.Them(ds[i]); } } return(kq); }
public DanhSachHinhHoc Tim_HCN_DT_Min(DanhSachHinhHoc a) { DanhSachHinhHoc kq = new DanhSachHinhHoc(); DanhSachHinhHoc DS = Tim_DS_HCN(a); float min = DS.TimMin_DT(); foreach (var item in a.DS_HH) { if (item.Tinh_DienTich() == min) { kq.Them(item); } } return(kq); }
//Các hàm thực hiện chức năng của menu public DanhSachHinhHoc Tim_HV_DT_Max(DanhSachHinhHoc a) { DanhSachHinhHoc kq = new DanhSachHinhHoc(); DanhSachHinhHoc DS = Tim_DS_HV(a); float max = DS.TimMax_DT(); foreach (var item in a.DS_HH) { if (item.Tinh_DienTich() == max) { kq.Them(item); } } return(kq); }
//Xoa hinh co cv lon nhat public void XoaHinhCoCVMax(DanhSachHinhHoc a) { float max = a.TimMax_CV(); DanhSachHinhHoc ds = new DanhSachHinhHoc(); foreach (var item in a.DSHinhHoc) { if (item.TinhChuVi() == max) { ds.Them(item); } } foreach (var item in ds.DSHinhHoc) { a.Xoa(item); } }
public void Xoa_Hinh_DT_Max(DanhSachHinhHoc a) { float max = a.TimMax_DT(); DanhSachHinhHoc DS_Xoa = new DanhSachHinhHoc(); foreach (var item in a.DS_HH) { if (item.Tinh_DienTich() == max) { DS_Xoa.Them(item); } } foreach (var item in DS_Xoa.DS_HH) { a.Xoa(item); } }
public void Xoa_Hinh_CV_Min(DanhSachHinhHoc a) { float min = a.TimMin_CV(); DanhSachHinhHoc DS_Xoa = new DanhSachHinhHoc(); foreach (var item in a.DS_HH) { if (item.Tinh_ChuVi() == min) { DS_Xoa.Them(item); } } foreach (var item in DS_Xoa.DS_HH) { a.Xoa(item); } }
public void XoaHinhCoDTMin(DanhSachHinhHoc a) { float min = a.TimMin_DT(); DanhSachHinhHoc ds = new DanhSachHinhHoc(); foreach (var item in a.DSHinhHoc) { if (item.TinhDienTich() == min) { ds.Them(item); } } foreach (var item in ds.DSHinhHoc) { a.Xoa(item); } }
//Tim hinh tron co ban kinh max public DanhSachHinhHoc TimHTBKMax(DanhSachHinhHoc a) { DanhSachHinhHoc ds = Tim_DS_HT(a); DanhSachHinhHoc kq = new DanhSachHinhHoc(); float max = ds.TimMax_BK(); for (int i = 0; i < ds.Dai; i++) { if (ds[i] is HinhTron) { HinhTron ht = (HinhTron)ds[i]; if (ht.BanKinh == max) { kq.Them(ds[i]); } } } return(kq); }
public DanhSachHinhHoc Tim_HT_BK_Max(DanhSachHinhHoc a) { DanhSachHinhHoc kq = new DanhSachHinhHoc(); DanhSachHinhHoc DS = Tim_DS_HT(a); float max = DS.TimMax_BK(); foreach (var item in a.DS_HH) { if (item is HinhTron) { HinhTron t = (HinhTron)item; if (t.bk == max) { kq.Them(item); } } } return(kq); }
public DanhSachHinhHoc HienThi_Hinh_DT_Tang(DanhSachHinhHoc a) { a.DS_HH.Sort((x, y) => x.Tinh_DienTich().CompareTo(y.Tinh_DienTich())); return(a); }
static void Main(string[] args) { QuanLyHinhHoc ql = new QuanLyHinhHoc(); DanhSachHinhHoc ds = new DanhSachHinhHoc(); while (true) { Console.Clear(); Console.WriteLine("==========================================="); Console.WriteLine("Nhap {0} de Thoat", (int)Menu.Thoat); Console.WriteLine("Nhap {0} de Nhap du lieu tu ban phim", (int)Menu.NhapTuBanPhim); Console.WriteLine("Nhap {0} de Nhap du lieu tu file", (int)Menu.NhapTuFile); Console.WriteLine("Nhap {0} de Xuat danh sach", (int)Menu.Xuat); Console.WriteLine("Nhap {0} de tim hinh vuong co dien tich lon nhat", (int)Menu.TimHinhVuongCoDTMax); Console.WriteLine("Nhap {0} de tim HCN co dien tich nho nhat", (int)Menu.TimHCNCosDTNhoNhat); Console.WriteLine("Nhap {0} de tim HT co ban kinh lon nhat", (int)Menu.TimHTCoBKMax); Console.WriteLine("Nhap {0} de Sap xep ds hinh vuong theo chieu tang giam cua chu vi", (int)Menu.SapXepHVTangChuVi); Console.WriteLine("Nhap {0} de Sap xep ds hinh tron theo chieu giam cua chu vi", (int)Menu.SapXepHTTangCv); Console.WriteLine("Nhap {0} de Sap xep ds dinh chu nhat tang theo chu vi", (int)Menu.SapXepHCNTangCV); Console.WriteLine("Nhap {0} de Tim hinh co dien tich lon nhat", (int)Menu.TimHinhCoDTMax); Console.WriteLine("Nhap {0} de tim hinh co chu vi nho nhat", (int)Menu.TimHinhCoCVMin); Console.WriteLine("Nhap {0} de hien thi tat ca cac hinh theo chieu giam cua dien tich", (int)Menu.HienThiTheoChieuTangDT); Console.WriteLine("Nhap {0} de hien thi tat ca cac hinh theo chieu tang cua chu vi", (int)Menu.HienThiTheoChieuGiamCV); Console.WriteLine("Nhap {0} de xoa cac hinh co dien tich nho nhat", (int)Menu.XoaCacHinhCoDTMin); Console.WriteLine("Nhap {0} de xoa cac hinh co chu vi lon nhat", (int)Menu.XoaCacHinhCoCVMax); Menu nhap = (Menu)int.Parse(Console.ReadLine()); switch (nhap) { case Menu.Thoat: return; case Menu.NhapTuBanPhim: { Console.Clear(); ds.NhapBangTay(); ds.Xuath(); } break; case Menu.NhapTuFile: { Console.Clear(); ds.NhapTuFile(); Console.WriteLine("Du lieu da duoc chuyen vao!"); } break; case Menu.Xuat: { Console.Clear(); ds.Xuat(); } break; case Menu.TimHinhVuongCoDTMax: { Console.Clear(); DanhSachHinhHoc kq1 = ql.TimHVDTMax(ds); DanhSachHinhHoc kq2 = ql.TimHVDTMin(ds); Console.WriteLine("Hinh vuong co dien tich lon nhat la: " + "\n"); Console.WriteLine(kq1); Console.WriteLine("Hinh vuong co dien tich nho nhat la: " + "\n"); Console.WriteLine(kq2); } break; case Menu.TimHCNCosDTNhoNhat: { Console.Clear(); DanhSachHinhHoc kq = ql.TimHCNDTMin(ds); Console.WriteLine("HCN Co dien tich nho nhat la: " + "\n"); Console.WriteLine(kq); } break; case Menu.TimHTCoBKMax: { Console.Clear(); DanhSachHinhHoc kq = ql.TimHTBKMax(ds); Console.WriteLine("Hinh tron co ban kinh lon nhat la:" + "\n"); Console.WriteLine(kq); } break; case Menu.SapXepHVTangChuVi: { Console.Clear(); DanhSachHinhHoc kq1 = ql.SapXepHVTangCV(ds); DanhSachHinhHoc kq2 = ql.SapXepHVGiamCV(ds); Console.WriteLine("Sap DSHV Tang theo chu vi:" + "\n" + "========================================="); Console.WriteLine(kq1 + "\n"); Console.WriteLine("Sap DSHV Giam theo chu vi:" + "\n" + "========================================="); Console.WriteLine(kq2); } break; case Menu.SapXepHTTangCv: { Console.Clear(); DanhSachHinhHoc kq1 = ql.SapXepHTTangCV(ds); DanhSachHinhHoc kq2 = ql.SapXepHTGiamCV(ds); Console.WriteLine("Sap DSHT Tang theo chu vi:" + "\n" + "========================================="); Console.WriteLine(kq1 + "\n"); Console.WriteLine("Sap DSHT Giam theo chu vi:" + "\n" + "========================================="); Console.WriteLine(kq2); } break; case Menu.SapXepHCNTangCV: { Console.Clear(); DanhSachHinhHoc kq1 = ql.SapXepHCNTangCV(ds); DanhSachHinhHoc kq2 = ql.SapXepHCNGiamCV(ds); Console.WriteLine("Sap DSHCN Tang theo chu vi:" + "\n" + "========================================="); Console.WriteLine(kq1 + "\n"); Console.WriteLine("Sap DSHCN Giam theo chu vi:" + "\n" + "========================================="); Console.WriteLine(kq2); } break; case Menu.TimHinhCoDTMax: { Console.Clear(); DanhSachHinhHoc kq1 = ql.TimHinhCoDTMax(ds); DanhSachHinhHoc kq2 = ql.TimHinhCoDTMin(ds); Console.WriteLine("Hinh co dien tich lon nhat la: " + "\n"); Console.WriteLine(kq1 + "\n"); Console.WriteLine("Hinh co dien tich nho nhat la: " + "\n"); Console.WriteLine(kq2); } break; case Menu.TimHinhCoCVMin: { Console.Clear(); DanhSachHinhHoc kq1 = ql.TimHinhCoCVMax(ds); DanhSachHinhHoc kq2 = ql.TimHinhCoCVMin(ds); Console.WriteLine("Hinh co chu vi lon nhat la: " + "\n"); Console.WriteLine(kq1 + "\n"); Console.WriteLine("Hinh co chu vi nho nhat la: " + "\n"); Console.WriteLine(kq2); } break; case Menu.HienThiTheoChieuTangDT: { Console.Clear(); Console.WriteLine(ql.SapXepDTGiam(ds)); } break; case Menu.HienThiTheoChieuGiamCV: { Console.Clear(); Console.WriteLine(ql.SapXepCVTang(ds)); } break; case Menu.XoaCacHinhCoCVMax: { Console.Clear(); Console.WriteLine("Hinh co chu vi lon nhat la: " + ql.TimHinhCoCVMax(ds)); Console.WriteLine("Nhan phim bat ky de xoa hinh co chu vi max!!"); Console.ReadKey(); ql.XoaHinhCoCVMax(ds); ds.Xuat(); } break; case Menu.XoaCacHinhCoDTMin: { Console.Clear(); Console.WriteLine("Hinh co dien tich nho nhat la: " + ql.TimHinhCoDTMin(ds)); Console.WriteLine("Nhan phim bat ky de xoa hinh co dien tich min!!"); Console.ReadKey(); ql.XoaHinhCoDTMin(ds); ds.Xuat(); } break; default: break; } Console.ReadLine(); } //ds.NhapTuFile(); //ql.NhapTuFile(); //ql.Xuat(); //Console.WriteLine("================="); //DanhSachHinhHoc kq = ql.SapXepHTGiamCV(ds); //Console.WriteLine(kq); //DanhSachHinhHoc kq = ql.SapXepDTGiam(); //Console.WriteLine(kq); //DanhSachHinhHoc kq = ql.TimHVDTMax(ds); //Console.WriteLine(kq); }
static void Main(string[] args) { DanhSachHinhHoc DS_HH = new DanhSachHinhHoc(); QuanLyHinhHoc QL_HH = new QuanLyHinhHoc(); while (true) { Console.Clear(); Console.WriteLine("".PadRight(20) + "HE THONG CHUC NANG"); Console.WriteLine("0. Thoat khoi chuong trinh "); Console.WriteLine("1. Nhap bang tay "); Console.WriteLine("2. Nhap tu file "); Console.WriteLine("3. Tim hinh vuong co dien tich lon nhat "); Console.WriteLine("4. Tim hinh chu nhat co dien tich nho nhat "); Console.WriteLine("5. Tim hinh tron co ban kinh lon nhat. "); Console.WriteLine("6. Sap xep danh sach hinh vuong theo chieu tang, giam cua chu vi "); Console.WriteLine("7. Sap xep danh sach hinh tron theo chieu tang, giam cua chu vi "); Console.WriteLine("8. Sap xep danh sach hinh chu nhat theo chieu tang, giam cua chu vi "); Console.WriteLine("9. Tim cac hinh co dien tich lon nhat, nho nhat "); Console.WriteLine("10. Tim cac hinh co chu vi lon nhat, nho nhat "); Console.WriteLine("11. Hien thi tat ca cac hinh theo chieu tang, giam cua dien tich "); Console.WriteLine("12. Hien thi tat ca cac hinh theo chieu tang, giam cua chu vi "); Console.WriteLine("13. Xoa cac hinh co dien tich nho nhat, lon nhat "); Console.WriteLine("14. Xoa cac hinh co chu vi nho nhat, lon nhat "); Console.Write("\nNhap so thu tu chuc nang can thuc hien: "); Menu menu = (Menu)int.Parse(Console.ReadLine()); Console.Clear(); switch (menu) { case Menu.Thoat: Console.WriteLine("0.Thoat khoi chuong trinh\n"); return; case Menu.Nhap_BangTay: Console.WriteLine("1.Nhap bang tay\n"); DS_HH.NhapBangTay(); DS_HH.Xuat_DS(); break; case Menu.Nhap_TuFile: Console.WriteLine("2.Nhap tu file\n"); DS_HH.DocTuFile(); DS_HH.Xuat_DS(); break; case Menu.Tim_HV_S_Max: Console.WriteLine("3.Tim hinh vuong co dien tich lon nhat\n"); QL_HH.Tim_HV_DT_Max(DS_HH).Xuat_DS(); break; case Menu.Tim_HCN_S_Min: Console.WriteLine("4.Tim hinh chu nhat co dien tich nho nhat\n"); QL_HH.Tim_HCN_DT_Min(DS_HH).Xuat_DS(); break; case Menu.Tim_HT_R_Max: Console.WriteLine("5.Tim hinh tron co ban kinh lon nhat.\n"); QL_HH.Tim_HT_BK_Max(DS_HH).Xuat_DS(); break; case Menu.SapXep_DSHV: Console.WriteLine("6.Sap xep danh sach hinh vuong theo chieu tang, giam cua chu vi\n"); Console.WriteLine("Danh sach ban dau:"); QL_HH.Tim_DS_HV(DS_HH).Xuat_DS(); Console.WriteLine("Danh sach hinh vuong sap xep theo chieu tang chu vi:"); QL_HH.SapXep_HV_Tang_CV(DS_HH).Xuat_DS(); Console.WriteLine("Danh sach hinh vuong sap xep theo chieu giam chu vi:"); QL_HH.SapXep_HV_Giam_CV(DS_HH).Xuat_DS(); break; case Menu.SapXep_DSHT: Console.WriteLine("7.Sap xep danh sach hinh tron theo chieu tang, giam cua chu vi\n"); Console.WriteLine("Danh sach ban dau:"); QL_HH.Tim_DS_HT(DS_HH).Xuat_DS(); Console.WriteLine("Danh sach hinh vuong sap xep theo chieu tang chu vi:"); QL_HH.SapXep_HT_Tang_CV(DS_HH).Xuat_DS(); Console.WriteLine("Danh sach hinh vuong sap xep theo chieu giam chu vi:"); QL_HH.SapXep_HT_Giam_CV(DS_HH).Xuat_DS(); break; case Menu.SapXep_DSHCN: Console.WriteLine("8.Sap xep danh sach hinh chu nhat theo chieu tang, giam cua chu vi\n"); Console.WriteLine("Danh sach ban dau:"); QL_HH.Tim_DS_HCN(DS_HH).Xuat_DS(); Console.WriteLine("Danh sach hinh vuong sap xep theo chieu tang chu vi:"); QL_HH.SapXep_HCN_Tang_CV(DS_HH).Xuat_DS(); Console.WriteLine("Danh sach hinh vuong sap xep theo chieu giam chu vi:"); QL_HH.SapXep_HCN_Giam_CV(DS_HH).Xuat_DS(); break; case Menu.Tim_Hinh_S_MaxMin: Console.WriteLine("9.Tim cac hinh co dien tich lon nhat, nho nhat\n"); Console.WriteLine("Hinh co dien tich lon nhat la:"); QL_HH.Tim_Hinh_DT_Max(DS_HH).Xuat_DS(); Console.WriteLine("Hinh co dien tich nho nhat la:"); QL_HH.Tim_Hinh_DT_Min(DS_HH).Xuat_DS(); break; case Menu.Tim_Hinh_C_MaxMin: Console.WriteLine("10.Tim cac hinh co chu vi lon nhat, nho nhat\n"); Console.WriteLine("Hinh co chu vi lon nhat la:"); QL_HH.Tim_Hinh_CV_Max(DS_HH).Xuat_DS(); Console.WriteLine("Hinh co chu vi nho nhat la:"); QL_HH.Tim_Hinh_CV_Min(DS_HH).Xuat_DS(); break; case Menu.HienThi_Hinh_S_TangGiam: Console.WriteLine("11.Hien thi tat ca cac hinh theo chieu tang, giam cua dien tich\n"); Console.WriteLine("Danh sach ban dau:"); DS_HH.Xuat_DS(); Console.WriteLine("Danh sach hinh theo chieu tang dien tich:"); QL_HH.HienThi_Hinh_DT_Tang(DS_HH).Xuat_DS(); Console.WriteLine("Danh sach hinh theo chieu giam dien tich:"); QL_HH.HienThi_Hinh_DT_Giam(DS_HH).Xuat_DS(); break; case Menu.HienThi_Hinh_C_TangGiam: Console.WriteLine("12.Hien thi tat ca cac hinh theo chieu tang, giam cua chu vi\n"); Console.WriteLine("Danh sach ban dau:"); DS_HH.Xuat_DS(); Console.WriteLine("Danh sach hinh theo chieu tang chu vi:"); QL_HH.HienThi_Hinh_DT_Tang(DS_HH).Xuat_DS(); Console.WriteLine("Danh sach hinh theo chieu giam chu vi:"); QL_HH.HienThi_Hinh_DT_Giam(DS_HH).Xuat_DS(); break; case Menu.Xoa_Hinh_S_MaxMin: Console.WriteLine("13.Xoa cac hinh co dien tich nho nhat, lon nhat\n"); Console.WriteLine("Danh sach ban dau:"); DS_HH.Xuat_DS(); Console.WriteLine("Danh sach sau khi xoa hinh co dien tich lon nhat:"); QL_HH.Xoa_Hinh_DT_Max(DS_HH); DS_HH.Xuat_DS(); Console.WriteLine("Danh sach sau khi xoa hinh co dien tich nho nhat:"); QL_HH.Xoa_Hinh_DT_Min(DS_HH); DS_HH.Xuat_DS(); break; case Menu.Xoa_Hinh_C_MaxMin: Console.WriteLine("14.Xoa cac hinh co chu vi nho nhat, lon nhat\n"); Console.WriteLine("Danh sach ban dau:"); DS_HH.Xuat_DS(); Console.WriteLine("Danh sach sau khi xoa hinh co chu vi lon nhat:"); QL_HH.Xoa_Hinh_CV_Max(DS_HH); DS_HH.Xuat_DS(); Console.WriteLine("Danh sach sau khi xoa hinh co chu vi nho nhat:"); QL_HH.Xoa_Hinh_CV_Min(DS_HH); DS_HH.Xuat_DS(); break; default: break; } Console.ReadKey(); } }
public DanhSachHinhHoc HienThi_Hinh_CV_Giam(DanhSachHinhHoc a) { a.DS_HH.Sort((x, y) => y.Tinh_ChuVi().CompareTo(x.Tinh_ChuVi())); return(a); }