Пример #1
0
        static void Main(string[] args)
        {
            man Wangking = new man();   //实例化一个对象

            Wangking.name = "xiaoji";
            Wangking.eag  = 25;
            Wangking.sex  = 1;
            Wangking.DrinkMilk();

            SuperMan guix = new SuperMan();

            guix.Name = "huangdi";  //只能通过属性访问字段
            guix.Age  = 20;
            guix.Sex  = 5;
            guix.DrinkMilk();
        }
Пример #2
0
        static void Main(string[] args)
        {
            //BatMan b = new BatMan("Ivan");
            //SuperMan s = new SuperMan("S***n");
            //CatWoman c = new CatWoman("Olga");
            //Loki l = new Loki("Petr");

            //SuperHero b = new BatMan("Ivan");
            //SuperHero s = new SuperMan("S***n");
            //SuperHero c = new CatWoman("Olga");
            //SuperHero l = new Loki("Petr");

            SuperHero[] mass = new SuperHero[10];

            Random rand = new Random();

            for (int i = 0; i < 10; i++)
            {
                int r = rand.Next(1, 4);
                if (r == 1)
                {
                    mass[i] = new SuperMan("Alex");
                }
                if (r == 2)
                {
                    mass[i] = new BatMan("Serezha");
                }
                if (r == 3)
                {
                    mass[i] = new CatWoman("Ira");
                }
                if (r == 4)
                {
                    mass[i] = new Thor("Igor");
                }
            }

            BatMan batman = new BatMan("Fedya");
            // batman.PolivatTsvets();

            SuperMan sm = new SuperMan("Vitya Yanukovich");

            WorkInSanatorij(sm);
        }