예제 #1
0
        public static void RandomWorker(ref Worker w)
        {
            Random r = new Random();

            switch (r.Next(1))
            {
            case 0:
                w = new WorkerA(r.Next(100));
                break;

            case 1:
                w = new WorkerB(r.Next(20000));
                break;

            default:
                w = new WorkerA(0);
                break;
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            // !Тут баг с заполнением массива (запускай через CTRL + F5)!

            // Заполнение массива wList
            WorkerList wList = new WorkerList(new Worker[10]);

            for (int i = 0; i < 10; i++)
            {
                Worker w = new WorkerA(0);
                Worker.RandomWorker(ref w);
                wList.wList[i] = new WorkerA(w);
            }


            // Считования из wList.
            foreach (var item in wList)
            {
                Console.WriteLine(item);
            }

            Console.ReadLine();
        }