Exemple #1
0
        public ServiceResult <DAGIAC> KhoiTao(string chuoiDaGiac)
        {
            var result = new ServiceResult <DAGIAC>();

            string[] M = chuoiDaGiac.Split('|');
            //"(2,3)(3,2)(3,4)"
            if (M.Length <= 2)
            {
                result.IsSuccess    = false;
                result.ErrorMessage = "Da giac khong hop le";

                return(result);
            }
            DAGIAC dg = new DAGIAC();

            foreach (string s in M)
            {
                DIEM a = new DIEM(s);
                dg.dsDinh.Add(a);
            }

            result.IsSuccess = true;
            result.Data      = dg;

            return(result);
        }
Exemple #2
0
    public static DAGIAC Doc(String TenFile)
    {
        String Chuoi = XuLyTapTin.Doc(TenFile);
        DAGIAC kq    = KhoiTao(Chuoi);

        return(kq);
    }
Exemple #3
0
    public static Double TinhChuVi(DAGIAC D)
    {
        Double kq = 0;

        for (int i = 1; i < D.Dinh.Length; i++)
        {
            kq = kq + XuLyDiem.Khoang_cach(D.Dinh[i - 1], D.Dinh[i]);
        }
        kq = kq + XuLyDiem.Khoang_cach(D.Dinh[D.Dinh.Length - 1], D.Dinh[0]);
        return(kq);
    }
    static void Main(string[] args)
    {
        DAGIAC D     = XuLyDaGiac.Doc("DaGiac.txt");
        String Chuoi = "Du lieu khong hop le";

        if (D.Dinh != null)
        {
            Double kq = XuLyDaGiac.TinhChuVi(D);
            Chuoi = "Da giac D" + XuLyDaGiac.XuatChuoi(D) + "\n";
            Chuoi = Chuoi + " co chu vi = " + XuLySoThuc.XuatChuoi(kq);
        }
        XuLyChuoi.Xuat(Chuoi);
    }
Exemple #5
0
    public static String XuatChuoi(DAGIAC D)
    {
        String kq = "(";

        for (int i = 0; i < D.Dinh.Length; i++)
        {
            kq = kq + XuLyDiem.XuatChuoi(D.Dinh[i]);
            if (i < D.Dinh.Length - 1)
            {
                kq = kq + ChuoiPhanCach;
            }
        }
        kq = kq + ")";
        return(kq);
    }