コード例 #1
0
ファイル: Program.cs プロジェクト: GermanKurochkin/lab14
        public void Add()
        {
            int             menu;
            Random          rand = new Random();
            InternalCEngine iEng = new InternalCEngine();
            Diesel          dies = new Diesel();
            Engine          eng  = new Engine();
            TurbojetEngine  turb = new TurbojetEngine();

            menu = rand.Next(4);

            switch (menu)
            {
            case 0:
                stackEng.Push(eng.MakeRandom());
                listEng.Add(eng.MakeRandom());
                break;

            case 1:
                stackEng.Push(dies.MakeRandom());
                listEng.Add(dies.MakeRandom());
                break;

            case 2:
                stackEng.Push(iEng.MakeRandom());
                listEng.Add(iEng.MakeRandom());
                break;

            case 3:
                stackEng.Push(turb.MakeRandom());
                listEng.Add(turb.MakeRandom());
                break;
            }
            Size++;
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: GermanKurochkin/lab14
        public Collections(int size)
        {
            Random rand = new Random();
            int    menu;

            Size = size;
            InternalCEngine iEng = new InternalCEngine();
            Diesel          dies = new Diesel();
            Engine          eng  = new Engine();
            TurbojetEngine  turb = new TurbojetEngine();

            for (int i = 0; i < size; i++)
            {
                menu = rand.Next(4);

                switch (menu)
                {
                case 0:
                    stackEng.Push(eng.MakeRandom());
                    listEng.Add(eng.MakeRandom());
                    break;

                case 1:
                    stackEng.Push(dies.MakeRandom());
                    listEng.Add(dies.MakeRandom());
                    break;

                case 2:
                    stackEng.Push(iEng.MakeRandom());
                    listEng.Add(iEng.MakeRandom());
                    break;

                case 3:
                    stackEng.Push(turb.MakeRandom());
                    listEng.Add(turb.MakeRandom());
                    break;
                }
            }
        }