コード例 #1
0
        public IStackVagon GetRandStackVagon(int n)
        {
            IStackVagon stackVagon = new StackVagon1();
            Random      r          = new Random();

            for (int i = 0; i < n; i++)
            {
                stackVagon.Push(GetVagon(r.Next(0, 2)));
            }
            return(stackVagon);
        }
コード例 #2
0
        public IStackVagon GetStackVagonFromFile(string fileName)
        {
            IStackVagon  stackVagon = new StackVagon1();
            StreamReader sr         = new StreamReader(fileName);
            string       strVagons  = sr.ReadToEnd();

            string[] masStrVagonType = strVagons.Split(';');
            for (int i = 0; i < masStrVagonType.Length; i++)
            {
                stackVagon.Push(new Vagon {
                    Type = int.Parse(masStrVagonType[i])
                });
            }
            return(stackVagon);
        }