예제 #1
0
        private static List <KhuDat> InputListKD()
        {
            List <KhuDat> listKhuDat = new List <KhuDat>();

            Console.Write("Input N=");
            int N = Convert.ToInt32(Console.ReadLine());
            int chon;

            for (int i = 0; i < N; i++)
            {
                Console.WriteLine("\n --- Input 1: Input Khu Dat || Input 2: Input Nha Pho || Input 3: Input Chung Cu---");
                chon = Int32.Parse(Console.ReadLine());
                switch (chon)
                {
                case 1:
                    Console.WriteLine("- Input Khu Dat");
                    KhuDat kd = new KhuDat();
                    kd.Input();
                    listKhuDat.Add(kd);
                    break;

                case 2:
                    Console.WriteLine("- Input Nha Pho");
                    NhaPho nh = new NhaPho();
                    nh.Input();
                    listKhuDat.Add(nh);
                    break;

                case 3:
                    Console.WriteLine("- Input Chung Cu");
                    ChungCu ch = new ChungCu();
                    ch.Input();
                    listKhuDat.Add(ch);
                    break;

                default:
                    break;
                }
            }
            return(listKhuDat);
        }
예제 #2
0
        private static List <DiaOcD> inputListDiaOc()
        {
            System.Console.WriteLine("Nhap tong so dia oc D ");
            int           N          = Convert.ToInt32(Console.ReadLine());
            List <DiaOcD> listDiaOcD = new List <DiaOcD>();

            System.Console.WriteLine("\n ===Nhap danh sach dia oc D===");
            for (int i = 0; i < N; i++)
            {
                System.Console.WriteLine("\n - 1.Khu dat 2. Nha Pho 3.Chung Cu \nNhap dia oc {0}", i + 1);
                int    choice = Convert.ToInt32(Console.ReadLine());
                DiaOcD dia;
                switch (choice)
                {
                case 1:
                    dia = new KhuDat();
                    dia.Input();
                    listDiaOcD.Add(dia);
                    break;

                case 2:
                    dia = new NhaPho();
                    dia.Input();
                    listDiaOcD.Add(dia);
                    break;

                case 3:
                    dia = new ChungCu();
                    dia.Input();
                    listDiaOcD.Add(dia);
                    break;

                default:
                    System.Console.WriteLine("ko hieu");
                    break;
                }
            }
            return(listDiaOcD);
        }