Пример #1
0
        public void ThemHinhTaiViTri(int location, int typeList)
        {
            HinhHoc hh = new HinhHoc();

            switch (typeList)
            {
            case 1:
                WriteLine("\nHinh Vuong >>");
                hh = new HinhTron();
                break;

            case 2:
                WriteLine("\nHinh Vuong >>");
                hh = new HinhVuong();
                break;

            case 3:
                WriteLine("\nHinh chu nhat >>");
                hh = new HinhChuNhat();
                break;

            default:
                WriteLine("\nCo loi gi do da xay ra! Out...");
                break;
            }
            ListHinhHoc.Add(hh.Nhap());
            ListHinhHoc.Insert(location, hh);
        }
Пример #2
0
 private bool TrungKieuHinh(HinhHoc hh, TypeList typeList)
 {
     return(typeList == TypeList.TatCaHinh ||
            (hh is HinhVuong && typeList == TypeList.HinhVuong) ||
            (hh is HinhTron && typeList == TypeList.HinhTron) ||
            (hh is HinhChuNhat && typeList == TypeList.HinhChuNhat));
 }
Пример #3
0
 public float TinhChuVi(HinhHoc hh)
 {
     if (hh is HinhVuong)
     {
         return(((HinhVuong)hh).TinhChuVi());
     }
     if (hh is HinhTron)
     {
         return(((HinhTron)hh).TinhChuVi());
     }
     if (hh is HinhChuNhat)
     {
         return(((HinhChuNhat)hh).TinhChuVi());
     }
     return(0);
 }
Пример #4
0
        public void Nhap()
        {
            HinhHoc hh         = new HinhHoc();
            string  isContinue = null;

            do
            {
                Write("\nBan muon nhap hinh gi (1 - HV, 2 - HT, 3 - HCN) >> ");
                int type = int.Parse(ReadLine());
                switch (type)
                {
                case 1:
                    WriteLine("\nHinh Vuong >>");
                    hh = new HinhTron();
                    break;

                case 2:
                    WriteLine("\nHinh Vuong >>");
                    hh = new HinhVuong();
                    break;

                case 3:
                    WriteLine("\nHinh chu nhat >>");
                    hh = new HinhChuNhat();
                    break;

                default:
                    WriteLine("Co loi gi do da xay ra! Vui long kiem tra lai");
                    break;
                }
                ListHinhHoc.Add(hh.Nhap());
                WriteLine("\n\tBan co muon nhap nua khong ?");
                Write("Nhan phim bat ki de tiep tuc. Go 'No' neu khong! >> ");
                isContinue = ReadLine().ToUpper();
            } while (isContinue != "NO");
        }
Пример #5
0
 public void Xoa(HinhHoc geometry)
 {
     ListHinhHoc.Remove(geometry);
 }
Пример #6
0
 public void Them(HinhHoc geometry)
 {
     ListHinhHoc.Add(geometry);
 }