예제 #1
0
        //Nhap tu ban phim
        public void NhapBangTay()
        {
            string line = "";

            do
            {
                Console.WriteLine("Xin moi nhap thong tin: Hinh vuong(vd: HV Canh), Hinh tron(vd: HT banKinh), Hinh CN(vd: HCN Dai Rong) :");

a:
                line = Console.ReadLine();
                string[] str = line.Split(' ');
                if (str[0] == "HV")
                {
                    DanhSachHV.Them(new HinhVuong(float.Parse(str[1])));
                }
                else if (str[0] == "HT")
                {
                    DanhSachHT.Them(new HinhTron(float.Parse(str[1])));
                }
                else if (str[0] == "HCN")
                {
                    DanhSachHCN.Them(new HinhChuNhat(float.Parse(str[1]), float.Parse(str[2])));
                }
                else
                {
                    return;
                }
                Console.WriteLine("Xin moi nhap tiep thong tin hoac Nhan phim bat ky de xuat danh sach hinh hoc!...");
                goto a;
            } while (line == null);
        }
예제 #2
0
        /// <summary>
        /// Đọc dữ liệu từ tập tin
        /// </summary>
        public void DocTuFile()
        {
            string       path = @"data.txt";
            StreamReader sr   = new StreamReader(path);
            string       s    = "";

            while ((s = sr.ReadLine()) != null)
            {
                string[] t = s.Split(' ');
                if (t[0] == "HT")
                {
                    DS_HT.Them(new HinhTron(float.Parse(t[1])));
                }
                else if (t[0] == "HV")
                {
                    DS_HV.Them(new HinhVuong(float.Parse(t[1])));
                }
                else
                {
                    DS_HCN.Them(new HinhChuNhat(float.Parse(t[1]), float.Parse(t[2])));
                }
            }
        }
예제 #3
0
        public DanhSachHinhVuong TimDTMax()
        {
            DanhSachHinhVuong kq  = new DanhSachHinhVuong();
            float             max = TimMax();

            foreach (var item in DanhSachHinhV)
            {
                if (item.DT == max)
                {
                    kq.Them(item);
                }
            }
            return(kq);
        }