Esempio n. 1
0
 public string GenerateContentsString(StackQueue <string> data)
 {
     if (data.Count() == 0)
     {
         return("");
     }
     if (data.Count() == 1)
     {
         return(data.Dequeue());
     }
     else
     {
         var stackBuffer = data.Dequeue();
         return(GenerateContentsString(data) + "\n" + stackBuffer);
     }
 }
Esempio n. 2
0
        public override void ConstructData(string[] paramArgs = null)
        {
            base.ConstructData(paramArgs);

            dataBuffer = new List <string>();
            bool input = true;

            foreach (string param in paramArgs)
            {
                if (param == "generate")
                {
                    input = false;
                    Random random = new Random(Guid.NewGuid().GetHashCode());
                    for (int i = 0; i < this._words; i++)
                    {
                        var length = random.Next(3, 10);
                        var word   = generateRandomString(length, random);
                        if (paramArgs.Contains("numbertagwords"))
                        {
                            word = (i + 1) + " " + word;
                        }
                        if (paramArgs.Contains("printwords"))
                        {
                            Console.WriteLine(i + " " + word);
                        }
                        dataBuffer.Add(word);
                    }
                }
            }
            while (input)
            {
                var line = Console.ReadLine();
                if (line == null || line == "")
                {
                    input = false;
                    break;
                }

                if (paramArgs.Contains("numbertagwords"))
                {
                    line = (dataBuffer.Count() + 1) + " " + line;
                }
                dataBuffer.Add(line);
            }
            data = new StackQueue <string>(dataBuffer);//commit the buffer into the stack
        }