Exemple #1
0
        public DanhSachAnPham TimTuaDeDaiNhat(DanhSachAnPham a)
        {
            DanhSachAnPham kq  = new DanhSachAnPham();
            int            max = a.TimTuaDeMax();

            foreach (var item in a.ds)
            {
                if (item is Sach)
                {
                    Sach s = (Sach)item;
                    if (s.TuaDe.Length == max)
                    {
                        kq.Them(item);
                    }
                }
                else if (item is TapChi)
                {
                    TapChi tc = (TapChi)item;
                    if (tc.TuDe.Length == max)
                    {
                        kq.Them(item);
                    }
                }
            }
            return(kq);
        }
Exemple #2
0
        public int TimTuaDeMin()
        {
            int min = int.MaxValue;

            foreach (var item in ds)
            {
                if (item is Sach)
                {
                    Sach s = (Sach)item;
                    if (min > s.TuaDe.Length)
                    {
                        min = s.TuaDe.Length;
                    }
                }
                else if (item is TapChi)
                {
                    TapChi tc = (TapChi)item;
                    if (min > tc.TuDe.Length)
                    {
                        min = tc.TuDe.Length;
                    }
                }
            }
            return(min);
        }
Exemple #3
0
        public int TimTuaDeMax()
        {
            int max = int.MinValue;

            foreach (var item in ds)
            {
                if (item is Sach)
                {
                    Sach s = (Sach)item;
                    if (max < s.TuaDe.Length)
                    {
                        max = s.TuaDe.Length;
                    }
                }
                else if (item is TapChi)
                {
                    TapChi tc = (TapChi)item;
                    if (max < tc.TuDe.Length)
                    {
                        max = tc.TuDe.Length;
                    }
                }
            }
            return(max);
        }
Exemple #4
0
        public int TimMaxBV()
        {
            int max = int.MinValue;

            foreach (var item in ds)
            {
                if (item is TapChi)
                {
                    TapChi t = (TapChi)item;
                    if (max < t.SoBaiViet)
                    {
                        max = t.SoBaiViet;
                    }
                }
            }
            return(max);
        }
Exemple #5
0
        public int TimMinBV()
        {
            int min = int.MaxValue;

            foreach (var item in ds)
            {
                if (item is TapChi)
                {
                    TapChi t = (TapChi)item;
                    if (min > t.SoBaiViet)
                    {
                        min = t.SoBaiViet;
                    }
                }
            }
            return(min);
        }
Exemple #6
0
        public DanhSachAnPham TimTCBVMin(DanhSachAnPham a)
        {
            DanhSachAnPham ds  = TimDSTapChi(a);
            DanhSachAnPham kq  = new DanhSachAnPham();
            int            min = ds.TimMinBV();

            for (int i = 0; i < ds.Dai(); i++)
            {
                if (ds[i] is TapChi)
                {
                    TapChi tc = (TapChi)ds[i];
                    if (tc.SoBaiViet == min)
                    {
                        kq.Them(ds[i]);
                    }
                }
            }
            return(kq);
        }