public HomeModule() { Get["/"] = _ => { return View["index.html"]; }; Post["/result"] = _ => { RepeatCounter formRepeatCounter = new RepeatCounter(Request.Form["input-word"], Request.Form["input-list"]); string firstString = formRepeatCounter.GetStringOfWords(); string cleanString = formRepeatCounter.RemovePunctuation(firstString); string findWord = formRepeatCounter.GetWord(); int countWords = formRepeatCounter.CountRepeats(findWord, cleanString); return View["result.cshtml", formRepeatCounter]; }; Post["/warandpeace"] = _ => { RepeatCounter wapRepeatCounter = new RepeatCounter(Request.Form["input-word"], Request.Form["input-word"]); string readWarAndPeace = wapRepeatCounter.ReadAFile(); wapRepeatCounter.SetStringOfWords(readWarAndPeace); string firstString = wapRepeatCounter.GetStringOfWords(); string cleanString = wapRepeatCounter.RemovePunctuation(firstString); string findWord = wapRepeatCounter.GetWord(); int countWords = wapRepeatCounter.CountRepeats(findWord, cleanString); return View["warandpeace.cshtml", wapRepeatCounter]; }; }
public void Test6_RegognizeWordInSentence_true() { RepeatCounter checkNewWord = new RepeatCounter("the", "the blue jays rock"); int result = checkNewWord.CountRepeats(); Assert.Equal(1, result); }
public void Test5_recognizesWordNotPresent_true() { RepeatCounter checkNewWord = new RepeatCounter("the", "blue jays rock"); int result = checkNewWord.CountRepeats(); Assert.Equal(0, result); }
public void Test7_RecognizeMulitipleWordsInSentence_true() { RepeatCounter checkNewWord = new RepeatCounter("the", "the blue jays rock the theater"); int result = checkNewWord.CountRepeats(); Assert.Equal(2, result); }
public void Test2_LetterDontMatch_true() { //arrange RepeatCounter checkNewWord = new RepeatCounter("a", "b"); //act int result = checkNewWord.CountRepeats(); //Assert Assert.Equal(0, result); }
public void Test1_RepeatCounterGetA_true() { //arrange RepeatCounter checkNewWord = new RepeatCounter("a", "a"); //act int result = checkNewWord.CountRepeats(); //Assert Assert.Equal(1, result); }
public HomeModule() { Get["/"] = _ => { return View["index.cshtml"]; }; Post["/result"] = _ => { RepeatCounter newWord = new RepeatCounter ( Request.Form["new-word"], Request.Form["new-sentence"]); return View["result.cshtml", newWord]; }; }
public void Test4_TwoWordsReturnOne_true() { //arrange RepeatCounter checkNewWord = new RepeatCounter("and", "and"); //act int result = checkNewWord.CountRepeats(); //Assert Assert.Equal(1, result); }
public void FindWord_FindsWordInStringOfMultipleWords_DisplaysTrueIfFound() { // Arrange string testWord = "antelope"; string testString = "An antelope is like a gazelle in a way but it begins with an A actually."; RepeatCounter testRepeatCounter = new RepeatCounter(testWord, testString); // Act string resultString = testRepeatCounter.FindWord(testWord, testString); // Assert Console.WriteLine("Spec 4 expected: " + testString + " Spec 4 actual: " + resultString); Assert.Equal(resultString, "True"); }
public void CountRepeats_CountsWordReptitionInStringOfMultipleWords_ReturnsCountOfRepeats() { // Arrange string testWord = "antelope"; string testString = "An antelope is like a gazelle in a way but it begins with an A actually."; int testCount = 1; RepeatCounter testRepeatCounter = new RepeatCounter(testWord, testString); // Act int resultCount = testRepeatCounter.CountRepeats(testWord, testString); // Assert Console.WriteLine("Spec 5 expected: " + testCount + " Spec 5 actual: " + resultCount); Assert.Equal(testCount, resultCount); }
public HomeModule() { Get["/"] = _ => { return(View["index.cshtml"]); }; Post["/result"] = _ => { string sentence = Request.Form["sentence"]; string wordSelect = Request.Form["word"]; RepeatCounter newCounter = new RepeatCounter(sentence, wordSelect); return(View["results.cshtml", newCounter]); }; }
public static void Main() { Console.WriteLine("Welcome to the Word Counter!"); Console.WriteLine("Please enter a word"); string newWord = Console.ReadLine(); Console.WriteLine("Please ender a sentence"); string newSentence = Console.ReadLine(); RepeatCounter newCounter = new RepeatCounter(newWord, newSentence); int finalOutput = newCounter.CountWord(); Console.WriteLine("your word " + "~ " + newWord + " ~" + " repeats " + finalOutput + " time(s) in your sentence."); }
public void FindWord_FindsWordInStringOfMultipleWordsCapitalizedOrNot_ReturnsCountOfRepeatsRegardlessOfCase() { // Arrange string inputWord = "a"; string testWord = inputWord.ToUpper(); string testString = "An antelope is like a gazelle in a way but it begins with an A actually."; int testCount = 3; RepeatCounter testRepeatCounter = new RepeatCounter(testWord, testString); // Act int resultCount = testRepeatCounter.CountRepeats(testWord, testString); // Assert Console.WriteLine("Spec 6 expected: " + testCount + " Spec 6 actual: " + resultCount); Assert.Equal(testCount, resultCount); }
static void Main() { Welcome(); Console.WriteLine("Please enter a word."); string Word = Console.ReadLine(); Console.WriteLine("Please enter a sentence that uses that word at least once."); string Sentence = Console.ReadLine(); RepeatCounter NeedsCount = new RepeatCounter(Word, Sentence); NeedsCount.ValidInputCheck(Word); NeedsCount.ValidInputCheck(Sentence); Console.WriteLine("Your sentence contains the word " + Word + " " + NeedsCount.WordCount() + " time(s)."); }
public HomeModule() { Get["/"] = _ => { return(View["index.cshtml"]); }; Post["/count"] = _ => { RepeatCounter newRepeatCounter = new RepeatCounter(Request.Form["search-word"], Request.Form["search-string"]); newRepeatCounter.CountRepeats(); return(View["word_count.cshtml", newRepeatCounter]); }; }
public static void Main() { System.Console.WriteLine("Find the word in the sentence!"); System.Console.WriteLine("Please enter a word: "); string userWord = Console.ReadLine(); System.Console.WriteLine("Please enter the sentence you'd like to search: "); string userSentence = Console.ReadLine(); RepeatCounter newRepeatCounter = new RepeatCounter(userWord, userSentence); int result = newRepeatCounter.GetOccurenceCount(); System.Console.WriteLine("------------------------------------"); System.Console.WriteLine($"The word {userWord} appeared {result} time(s) in the sentence: '{userSentence}'"); }
public static void Main() { Console.WriteLine("Enter a word"); string inputWord = Console.ReadLine(); Console.WriteLine("Enter a sentence or list of words"); string inputSentence = Console.ReadLine(); RepeatCounter newRepeatCounter = new RepeatCounter(inputWord, inputSentence); int count = newRepeatCounter.CountMatching(); Console.WriteLine("The word *" + inputWord + "*" + " was entered " + count + " times"); }
public static string GetUserWord() { try { Console.WriteLine("\n Please enter a word:"); string userInput = Console.ReadLine(); string userWord = RepeatCounter.ValidateWord(userInput); return(userWord); } catch (Exception ex) { Console.WriteLine(ex.Message); return("error"); } }
public void Test1_RepeatCounterGetA_true() { //arrange string word = "a"; RepeatCounter checkNewWord = new RepeatCounter(word,""); //act..... string checkWord = checkNewWord.GetWord(); //Assert Assert.Equal(word, checkWord); // Test2_RepeatCounterGetThe_true() // }
public HomeModule() { Get["/"] = _ => { return(View["index.cshtml"]); }; Get["/results"] = _ => { return(View["index.cshtml"]); }; Post["/results"] = _ => { RepeatCounter newRepeatCounter = new RepeatCounter(Request.Form["user-word"], Request.Form["user-sentence"]); return(View["results.cshtml", newRepeatCounter]); }; }
public static string GetUserSentence() { try { Console.WriteLine("\n Please enter a sentence:"); string inputSentence = Console.ReadLine(); string userSentence = RepeatCounter.ValidateSentence(inputSentence); return(userSentence); } catch (Exception ex) { Console.WriteLine(ex.Message); return("error"); } }
public static void Main() { Console.WriteLine("Welcome, please enter a sentence and a word to check the occurence of your word in your sentence."); Console.WriteLine("Enter a sentence: "); string userInputSentence = Console.ReadLine(); Console.WriteLine("Enter a word: "); string userInputWord = Console.ReadLine(); RepeatCounter newUserInput = new RepeatCounter(userInputWord, userInputSentence); string userWord = newUserInput.GetUserWord(); string userSentence = newUserInput.GetUserSentence(); int resultCheckCount = Check.CheckNumberOccurence(userSentence, userWord); Console.WriteLine("Your word appears " + resultCheckCount + " times in your sentence."); }
public static void Main() { string word = RepeatCounter.GrabWord(); string sentence = RepeatCounter.GrabSentence(); int counter = RepeatCounter.userStringToCounter(word, sentence); if (counter > 0) { Console.WriteLine("Your word appeared this many times:" + counter); } else { Console.WriteLine("Couldn't find your word") } }
//Adds user input to back end constructor. Will notify user if inputted word is not a 'real' word. public static string GetWord() { Console.WriteLine("Enter a word: "); string word = Console.ReadLine(); if (RepeatCounter.IsAWord(word)) { return(word.ToLower()); } else { Console.WriteLine("Hey, That's not a real word! But I'll search for it anyway"); return(word); } }
public static void Main() { Console.WriteLine("Hello, world! Welcome to The Word Counter Extraordinaire."); Console.WriteLine("Please enter a word."); string userWord = Console.ReadLine().ToLower(); Console.WriteLine("Great! Now please enter a sentence."); string userSentence = Console.ReadLine().ToLower(); RepeatCounter newCounter = new RepeatCounter(userWord, userSentence); int wordInstances = newCounter.CountWordInSentence(); Console.WriteLine("The word " + "'" + userWord + "'" + " appears " + wordInstances + " times in " + "'" + userSentence + "'"); Console.WriteLine("Thanks for playing!"); }
public HomeModule() { //Routing to the HomePage Get["/"] = _ => { return(View["index.cshtml"]); }; //Routing to the Result Page Post["/result"] = _ => { RepeatCounter newRepeatCounter = new RepeatCounter(); string result = newRepeatCounter.CountRepeats(Request.Form["inputWord"], Request.Form["inputSentence"]); string[] countResultData = { Request.Form["inputSentence"], Request.Form["inputWord"], result }; return(View ["results.cshtml", countResultData]); }; }
public static void Main() { Console.Clear(); Console.ForegroundColor = ConsoleColor.DarkYellow; TypeLine("Hello Word Conter"); TypeLine("To start playing first enter a word"); string word = Console.ReadLine().ToLower(); Console.ForegroundColor = ConsoleColor.DarkGreen; TypeLine("Now enter a sentence"); string sentence = Console.ReadLine().ToLower(); RepeatCounter newCounter = new RepeatCounter(word, sentence); int userResult = newCounter.RepeatWord(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("The word you entered " + word + "repeats " + userResult + " times in your sentence."); }
public void FindWord_FindsWordInStringOfMultipleWordsWithPunchtuation_ReturnsCountOfRepeatsRegardlessOfPunctuation() { // Arrange string inputWord = "actually"; string testWord = inputWord.ToUpper(); string testString = "An antelope is like a gazelle in a way but it begins with an A actually."; int testCount = 1; int resultCount = 0; RepeatCounter testRepeatCounter = new RepeatCounter(testWord, testString); string testCleanString = testRepeatCounter.RemovePunctuation(testString); // Act Console.WriteLine("Spec 7 pre-method-call resultCount value: " + resultCount); resultCount = testRepeatCounter.CountRepeats(testWord, testCleanString); // Assert Console.WriteLine("Spec 7 expected: " + testCount + " Spec 7 actual: " + resultCount); Assert.Equal(testCount, resultCount); }
public static void Main() { Console.Clear(); Console.ForegroundColor = ConsoleColor.DarkYellow; TypeLine("Welcome to the Word Counter program"); string inputWord = GetWord(); RepeatCounter newCount = new RepeatCounter(); bool wordValid = newCount.ValidateWord(inputWord); bool realWord = newCount.DictionaryCheck(inputWord); // if the filepath for the dictionary text file is not working properly, the program will exit after you enter the first word. to bypass this, comment out line 16 and use the bool value for realWord from line 18 instead // bool realWord = true; if (wordValid) { if (!realWord) { DoesntExist(); } string inputSent = GetSentence(); bool sentValid = newCount.ValidateSentence(inputSent); if (sentValid) { int result = newCount.CountWords(); Console.Clear(); Console.Write(Environment.NewLine); if (result == 1) { TypeLine("The word '" + newCount.RootWord + "' appears in the sentence you entered only " + result + " time. Yay!"); PlayAgain(); } else { TypeLine("The word '" + newCount.RootWord + "' appears in the sentence you entered " + result + " times. Yay!"); PlayAgain(); } } else if (!sentValid) { ErrorMessage("sentence"); } } else { ErrorMessage("word"); } }
public static void AskUser() { Console.WriteLine(">>> Enter a word to search for:"); string searchFor = Console.ReadLine(); newRepeatCounter = new RepeatCounter(searchFor); if (newRepeatCounter.IsValidInput()) { Console.WriteLine(">>> Enter a sentence:"); string sentence = Console.ReadLine(); newRepeatCounter = new RepeatCounter(searchFor, sentence); } else { Console.WriteLine(">>> Invalid input. Please enter only 1 word."); AskUser(); } }
public static void Main() { RepeatCounter Words123 = new RepeatCounter(); Console.WriteLine("Please enter a sentence."); string UserPhrase = Console.ReadLine(); Console.WriteLine("Please enter a word the check the previous sentence with."); string UserWord = Console.ReadLine(); while (UserWord.Contains(" ")) { Console.WriteLine("Please enter a single word."); UserWord = Console.ReadLine(); } int CountWords = Words123.wordCounter(UserPhrase, UserWord); Console.WriteLine(UserWord + " appears in (" + UserPhrase + ") " + CountWords + " times."); }
public static void Main() { Console.WriteLine("Enter Your Word."); string firstWord = Console.ReadLine(); RepeatCounter wordCount = new RepeatCounter(firstWord); Console.WriteLine("Enter Your Sentence."); string enterSentence = Console.ReadLine(); int wordSum = wordCount.CountWord(enterSentence); Console.WriteLine("Your Word Appears " + wordSum); Console.WriteLine("Would You Like To Restart: Y/N"); string restartGame = Console.ReadLine(); if (restartGame.Equals("Y")) { Main(); } }
public static void CountWord() { Console.Clear(); Console.WriteLine("Welcome, please enter a sentence and a word to check the occurence of your word in your sentence."); Console.Write("Enter a sentence: "); string userSentence = Console.ReadLine().ToLower(); Console.Write("Enter a word: "); string userWord = Console.ReadLine().ToLower(); RepeatCounter newUserInput = new RepeatCounter(userWord, userSentence); if (RepeatCounter.CheckValidInput() == true) { Console.WriteLine($"Your word \"{userWord}\" appears {RepeatCounter.SearchWords()} times in your sentence."); } else { Console.WriteLine($"Your word \"{userWord}\" does not exist in your sentence \"{userSentence}\""); } }
//Method that combines the cleaner with the counter from the backend public static void resultPrinter(string sentence, string word) { string cleaned = RepeatCounter.sentenceCleaner(sentence); int occur = RepeatCounter.countRepeats(cleaned, word); if (occur > 0) { Console.Write("Your word "); Console.ForegroundColor = ConsoleColor.Blue; Console.Write($"'{word}' "); Console.ResetColor(); Console.Write("repeats in the sentence you supplied "); Console.ForegroundColor = ConsoleColor.Blue; Console.Write($"{occur} "); Console.ResetColor(); Console.Write("time(s)."); } else { Console.WriteLine($"Looks like {word} does not exist in your sentence or there was a typo."); } }
public static bool RunProgramLoop() { bool view = false; string[] inputs = ReturnValidStrings(); RepeatCounter newCounter = new RepeatCounter(inputs[0], inputs[1]); string t = ""; if (newCounter.GetCount() > 1) { t = "times"; } else { t = "time"; } Console.WriteLine($"The word '{newCounter.Word}' appears {newCounter.GetCount()} {t} in the sentence '{newCounter.Sentence}' "); if (RepeatCounter.GetInstances().Count > 0) { Console.WriteLine(""); Console.WriteLine("If you want to try again, press Enter."); Console.WriteLine("If you want to [V]iew your previous entries, press V and enter."); string resp = Console.ReadLine().ToLower(); if (resp == "v") { view = true; } else { view = false; } } return(view); }
public static void Main() { Console.WriteLine("Welcome to Word Counter!"); Console.WriteLine("Enter a sentence:"); string sentence = Console.ReadLine(); Console.WriteLine("Enter a number you want us to count:"); string word = Console.ReadLine(); RepeatCounter newRepeatCounter = new RepeatCounter(sentence, word); Console.WriteLine("--------"); Console.WriteLine("The word " + "(" + newRepeatCounter.Word + ")" + " is displayed " + newRepeatCounter.GetRepeatWordFrequency() + " times within your sentence."); Console.WriteLine("--------"); Console.WriteLine("Would you like to play again? Enter Yes or No"); string userInput1 = Console.ReadLine().ToLower(); if (userInput1 == "yes") { Main(); } else if (userInput1 == "no") { Console.WriteLine("Thanks for playing!"); } else { Console.WriteLine("Sorry we didn't get that. Please enter 'Yes' to play again, or 'No' to quit"); string userInput2 = Console.ReadLine(); if (userInput2 == "yes") { Main(); } else { Console.WriteLine("Thanks for playing!"); } } }
public static void StartWordCounter() { string validatedWord = GetUserWord(); if (validatedWord == "invalid input") { Console.Clear(); Console.WriteLine($"\n {validatedWord}"); StartWordCounter(); } else if (validatedWord == "error") { StartWordCounter(); } else { string validatedSentence = GetUserSentence(); if (validatedSentence == "invalid input") { Console.Clear(); string confusedArt = @"¯\_(ツ)_/¯"; Console.WriteLine($"\n {validatedSentence} \n \n {confusedArt} \n Let's try this again, from the beginning!"); StartWordCounter(); } else if (validatedSentence == "error") { StartWordCounter(); } else { Console.Clear(); RepeatCounter.AddMatchesToList(validatedWord, validatedSentence); DisplayNumberOfMatches(validatedWord, validatedSentence); } } }
public static void Main() { Console.Write("Enter a single word: "); string inputWord = Console.ReadLine(); RepeatCounter counter = new RepeatCounter(inputWord); Console.Write("Enter a series of words: "); string inputSentence = Console.ReadLine(); inputWord = counter.RemovePunctuation(inputWord); inputSentence = counter.RemovePunctuation(inputSentence); counter = new RepeatCounter(inputWord, inputSentence); if ((counter.StringCheck(counter.SingleWord)) && (counter.StringCheck(counter.MultipleWords)) && (counter.SpaceCheck(counter.SingleWord)) && (counter.LetterCheck(counter.MultipleWords))) { int countResult = counter.AddCount(counter.SplitString(counter.MultipleWords)); Console.WriteLine("Total matches: " + countResult); } else { Console.WriteLine("Please enter both a single word and a sentence."); Main(); } }
public void RepeatCounterTest1_Identical_True() { RepeatCounter testRepeatCounter = new RepeatCounter("A", "A"); Assert.Equal(1, testRepeatCounter.CountRepeats()); }
public void RepeatCounterTest_PartialMatches_False() { RepeatCounter testRepeatCounter = new RepeatCounter("ham", "I love ham on hamburgers"); Assert.Equal(1, testRepeatCounter.CountRepeats()); }
public void RepeatCounterTest_Count_True() { RepeatCounter testRepeatCounter = new RepeatCounter("A", "A A A"); Assert.Equal(3, testRepeatCounter.CountRepeats()); }
public void RepeatCounter_Test3_SplitInput2Sentence_ReturnWordCount() { RepeatCounter newCountRepeats = new RepeatCounter("I", "I am who I say I am"); Assert.Equal(3, newCountRepeats.CountRepeats()); }
public void RepeatCounter_CreatesARepeatCounterObjectWithTwoStrings_ReturnsValueOfTwoStrings() { // Arrange string testWord = "antelope"; string testString = "An antelope is like a gazelle in a way but it begins with an A actually."; // Act RepeatCounter testRepeatCounter = new RepeatCounter(testWord, testString); string resultWord = testRepeatCounter.GetWord(); string resultString = testRepeatCounter.GetStringOfWords(); // Assert Console.WriteLine("Spec 1 expected: " + testWord + " Spec 1 actual: " + resultWord); Console.WriteLine("Spec 2 expected: " + testString + " Spec 2 actual: " + resultString); Assert.Equal(testWord, resultWord); Assert.Equal(testString, resultString); }
static void Main() { RepeatCounter.InitApp(); }