public void RandomBookTest(string bookTitle, int numChapters, string pChapterHeadings, int minNumParagraphsPerChapter, int maxNumParagraphsPerChapter, int minNumSentencesPerParagraph, int maxNumSentencesPerParagraph) { RandomNumber rn = new RandomNumber(); RandomDocument rd = new RandomDocument(); string theEndText = "Finis ... The End"; string book = string.Empty; string[] chapterHeadings = null; try { _msg.Length = 0; _msg.Append("RandomBookTest started ...\r\n"); Program._messageLog.WriteLine(_msg.ToString()); if (pChapterHeadings.Trim().Length > 0) { chapterHeadings = pChapterHeadings.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); } if (chapterHeadings == null) { book = rd.GenerateBook(bookTitle, numChapters, minNumParagraphsPerChapter, maxNumParagraphsPerChapter, minNumSentencesPerParagraph, maxNumSentencesPerParagraph); } else { book = rd.GenerateBook(bookTitle, theEndText, numChapters, chapterHeadings, minNumParagraphsPerChapter, maxNumParagraphsPerChapter, minNumSentencesPerParagraph, maxNumSentencesPerParagraph); } Program._messageLog.WriteLine(book); } catch (System.Exception ex) { _msg.Length = 0; _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex)); Program._messageLog.WriteLine(_msg.ToString()); AppMessages.DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToAppLog); } finally { _msg.Length = 0; _msg.Append("\r\n... RandomBookTest finished."); Program._messageLog.WriteLine(_msg.ToString()); } }
public void GenerateRandomBook() { RandomDocument randDoc = new RandomDocument(); int numChaptersToGenerate = 3; int numParagraphsPerChapter = 10; int numSentencesPerParagraph = 5; string[] chapterTitles = null; try { _msg.Length = 0; _msg.Append("GenerateRandomBook started ...\r\n"); Program._messageLog.WriteLine(_msg.ToString()); numChaptersToGenerate = Convert.ToInt32(_frm.txtNumChaptersToOutput.Text); numParagraphsPerChapter = Convert.ToInt32(_frm.txtNumParagraphsToOutput.Text); numSentencesPerParagraph = Convert.ToInt32(_frm.txtNumSentencesToOutput.Text); if (numParagraphsPerChapter < 5) { numParagraphsPerChapter = 5; } if (numSentencesPerParagraph < 5) { numSentencesPerParagraph = 5; } chapterTitles = new string[2]; chapterTitles[0] = "First Chapter Is This"; chapterTitles[1] = "The Second Chapter Makes an Appearance"; string book = randDoc.GenerateBook("Test Program Book", "*** THE END ***", numChaptersToGenerate, chapterTitles, numParagraphsPerChapter - 3, numParagraphsPerChapter + 3, numSentencesPerParagraph - 2, numSentencesPerParagraph + 3); _msg.Length = 0; _msg.Append(book); Program._messageLog.WriteLine(_msg.ToString()); } catch (System.Exception ex) { _msg.Length = 0; _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex)); Program._messageLog.WriteLine(_msg.ToString()); AppMessages.DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToAppLog); } finally { _msg.Length = 0; _msg.Append("\r\n... GenerateRandomBook finished."); Program._messageLog.WriteLine(_msg.ToString()); } }