Example #1
0
        private void buttonGenerate_Click(object sender, RoutedEventArgs e)
        {
            string resultString = string.Empty;

            try
            {
                if (radioSentence.IsChecked.Value)
                {
                    resultString = _gen.GenerateSentence(Convert.ToInt32(textSentence_MinWords.Text));
                }
                else if (radioWords.IsChecked.Value)
                {
                    resultString = _gen.GenerateWords(Convert.ToInt32(textWords_NumWords.Text));
                }
                else if (radioTitle.IsChecked.Value)
                {
                    resultString = _gen.GenerateTitle(Convert.ToInt32(textTitle_NumWords.Text));
                }
                else if (radioParagraphs.IsChecked.Value)
                {
                    resultString = _gen.GenerateParagraphs(Convert.ToInt32(textParagraphs_NumParagraphs.Text));
                }
                else
                {
                    throw new NotImplementedException();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
            textOutput.Text = resultString;
        }
Example #2
0
        static void TimeGenerateWords(GeneratorFacade gen, int numIterations, int numWords)
        {
            Stopwatch timer = new Stopwatch();

            timer.Start();
            for (int i = 0; i < numIterations; i++)
            {
                gen.GenerateWords(numWords);
            }
            timer.Stop();
            double baseGenTime = timer.ElapsedMilliseconds / 1000.0;

            Console.WriteLine(string.Format("Time to generate {0}x{1} words: {2:0.00} seconds",
                                            numIterations, numWords, baseGenTime));
        }
Example #3
0
 public string GetText(int noOfWords)
 {
     return(_generator.GenerateWords(noOfWords));
 }