Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        //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);
        }
Ejemplo n.º 6
0
        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);
            }
        }
Ejemplo n.º 7
0
        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);
            }
        }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
        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();
            }
        }
Ejemplo n.º 10
0
 public DanhSachHinhHoc HienThi_Hinh_CV_Giam(DanhSachHinhHoc a)
 {
     a.DS_HH.Sort((x, y) => y.Tinh_ChuVi().CompareTo(x.Tinh_ChuVi()));
     return(a);
 }
Ejemplo n.º 11
0
 public DanhSachHinhHoc HienThi_Hinh_DT_Tang(DanhSachHinhHoc a)
 {
     a.DS_HH.Sort((x, y) => x.Tinh_DienTich().CompareTo(y.Tinh_DienTich()));
     return(a);
 }