public static void Run(string text, IConsole console) { // Execute var result = ReverseText.Run(text); // Display result console.Out.WriteLine($"Result: { result }"); }
/// <summary> /// Checks if <paramref name="text"/> is a palindrome /// </summary> /// <param name="text">Text to check</param> /// <returns>true if <paramref name="text"/> is a palindrome, false otherwise</returns> /// <remarks> /// Where n is length of the text /// BEST CASE- TIME: Ω(n), MEMORY: Ω(n) /// AVERAGE CASE- TIME: Θ(n), MEMORY: Θ(n) /// WORST CASE- TIME: O(n), MEMORY: O(n) /// </remarks> public static bool IsPalindrome(string text) { if (text == null) { return(false); } var reversedText = ReverseText.Run(text); if (reversedText.Equals(text)) { return(true); } return(false); }
static void MenuJump1() { //try //{ int key = Convert.ToInt32(Console.ReadLine()); Console.ForegroundColor = ConsoleColor.DarkGreen; if (key <= 4 && key != 0) { switch (key) { case 1: Console.WriteLine("Your mom be going to reverse the text... \n"); ReverseText r = new ReverseText(); r.Act(); break; case 2: Console.WriteLine("Your mom be going to work encrypt the numbers!"); Menu1(); break; case 3: Console.WriteLine("Your mom be going to work decrypt the numbers!"); Pause(); break; case 4: Menu(); break; } } else { Console.WriteLine("\u0007 Shit, there's no such section!"); MenuJump1(); } //} //catch (Exception mj1) //{ // Console.WriteLine("\u0007 error 001 \n enter the numbers from 1 to 3."); // Console.Read(); // StartUp(); //} }
static void JumpExit11() { //try //{ int key = Convert.ToInt32(Console.ReadLine()); Console.ForegroundColor = ConsoleColor.DarkCyan; if (key <= 4 && key != 0) { switch (key) { case 1: ReverseText r = new ReverseText(); r.Act(); break; case 2: Menu1(); break; case 3: StartUp(); break; case 0: Pause(); break; } } else { Console.WriteLine("\u0007 Shit, there's no such section!"); MenuJump0(); } //} //catch (Exception ej1) //{ // Console.WriteLine("\u0007 error 001 \n enter the numbers from 1 to 3."); // Console.Read(); // StartUp(); //} }
public void Run_WhenCalled_ReturnsValidResult(string text, string expected) { var actual = ReverseText.Run(text); Assert.Equal(expected, actual); }