Пример #1
0
        public void NhapDanhsach()
        {
            Console.Write("Nhap so luong hinh chu nhat  : "); n = Convert.ToInt32(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                Console.WriteLine("Hinh thu {0}", i + 1);
                danhsach[i] = new Hinhchunhat();
                danhsach[i].Nhap();
                a = danhsach[0].GetDientich();
                if (danhsach[i].GetDientich() < a)
                {
                    a = danhsach[i].GetDientich();
                }
                S1 += danhsach[i].GetChuvi();
            }

            Console.Write("Nhap so luong hinh tron : "); m = Convert.ToInt32(Console.ReadLine());

            for (int i = 0; i < m; i++)
            {
                Console.WriteLine("Hinh thu {0}", i + 1);
                danhsach[i] = new Hinhtron();
                danhsach[i].Nhap();
                b = danhsach[0].GetDientich();
                if (danhsach[i].GetDientich() < b)
                {
                    b = danhsach[i].GetDientich();
                }
                S2 += danhsach[i].GetChuvi();
            }

            Console.Write("Nhap so luong hinh tam giac  : "); j = Convert.ToInt32(Console.ReadLine());

            for (int i = 0; i < j; i++)
            {
                Console.WriteLine("Hinh thu {0}", i + 1);
                danhsach[i] = new Tamgiac();
                danhsach[i].Nhap();
                c = danhsach[0].GetDientich();
                if (danhsach[i].GetDientich() < c)
                {
                    c = danhsach[i].GetDientich();
                }
                S3 += danhsach[i].GetChuvi();
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            Hinh tamgiac = new Tamgiac();

            Console.WriteLine("Chu vi = {0} Va Dien tich= {1} Hinh tamg giac ", tamgiac.GetChuvi(), tamgiac.GetDientich());
            Hinh hinhtron = new Hinhtron();

            Console.WriteLine("Chu vi = {0} Va Dien tich= {1} Hinh tron  ", hinhtron.GetChuvi(), hinhtron.GetDientich());
            Hinh hinhchunhat = new Hinhchunhat();

            Console.WriteLine("Chu vi = {0} Va Dien tich= {1} Hinh chu nhat  ", hinhchunhat.GetChuvi(), hinhchunhat.GetDientich());

            NhapHinh nhap = new NhapHinh();

            nhap.NhapDanhsach();
            Console.WriteLine("Hinh co dien tich lon nhat la : " + nhap.Kiemtra());
            Console.WriteLine("Tong chu vi cua cac hinh la : " + nhap.Tinhtongchuvi());
            Console.ReadKey();
        }