public static void EndProgram() { foreach (RepeatCounter i in RepeatCounter.GetInstances()) { Console.WriteLine(""); Console.WriteLine($"sentence, {i.Sentence}, contained, {i.Word}, count, {i.GetCount()}"); } Console.WriteLine(""); Console.WriteLine("Print Summary to .txt file? [Y]/[N]"); string resp = Console.ReadLine().ToLower(); if (resp.Contains("y")) { List <string> summ = new List <string> { }; foreach (RepeatCounter i in RepeatCounter.GetInstances()) { summ.Add($"sentence, {i.Sentence}, contained, {i.Word}, count, {i.GetCount()},"); } PrintSummary(summ); } else { Console.ReadLine(); Environment.Exit(0); } }
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); }