From 2996ba3760e4a77860c50dfa4c5349168c8a75ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Qui=C3=B1anola=20CJ?= Date: Sat, 28 Feb 2026 10:45:14 +0800 Subject: [PATCH 1/9] Implement StringService with text manipulation methods --- StringService.cs | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 StringService.cs diff --git a/StringService.cs b/StringService.cs new file mode 100644 index 0000000..f1ac2ee --- /dev/null +++ b/StringService.cs @@ -0,0 +1,61 @@ +using System; + +namespace StringProcessing.Services +{ + public class StringService + { + private string currentText = ""; + private string originalText = ""; + + public void SetText(string text) + { + currentText = text; + originalText = text; + } + + public string GetText() + { + return currentText; + } + + public void ToUpperCase() + { + currentText = currentText.ToUpper(); + } + + public void ToLowerCase() + { + currentText = currentText.ToLower(); + } + + public int CountCharacters() + { + return currentText.Length; + } + + public bool ContainsWord(string word) + { + return currentText.Contains(word); + } + + public void ReplaceWord(string oldWord, string newWord) + { + currentText = currentText.Replace(oldWord, newWord); + } + + public void ExtractSubstring(int startIndex, int length) + { + currentText = currentText.Substring(startIndex, length); + } + + public void TrimSpaces() + { + currentText = currentText.Trim(); + } + + public void ResetText() + { + currentText = originalText; + } + } +} From c85cdddd2dfb848872e725b902cc46345d08a110 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Qui=C3=B1anola=20CJ?= Date: Sat, 28 Feb 2026 10:51:13 +0800 Subject: [PATCH 2/9] Change menu header style in StringView --- StringView.cs | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 StringView.cs diff --git a/StringView.cs b/StringView.cs new file mode 100644 index 0000000..bb99c71 --- /dev/null +++ b/StringView.cs @@ -0,0 +1,113 @@ +using System; +using StringProcessing.Services; + +namespace StringProcessing.Views +{ + public class StringView + { + private StringService service = new StringService(); + private bool isRunning = true; + + public void Run() + { + while (isRunning) + { + DisplayMenu(); + Console.Write("Select option: "); + string choice = Console.ReadLine(); + + HandleChoice(choice); + } + } + + private void DisplayMenu() + { + Console.WriteLine("\n----- String Processing System -----"); + Console.WriteLine("1. Enter Text"); + Console.WriteLine("2. View Current Text"); + Console.WriteLine("3. Convert to UPPERCASE"); + Console.WriteLine("4. Convert to lowercase"); + Console.WriteLine("5. Count Characters"); + Console.WriteLine("6. Check if Contains Word"); + Console.WriteLine("7. Replace Word"); + Console.WriteLine("8. Extract Substring"); + Console.WriteLine("9. Trim Spaces"); + Console.WriteLine("10. Reset Text"); + Console.WriteLine("11. Exit"); + } + + private void HandleChoice(string choice) + { + switch (choice) + { + case "1": + Console.Write("Enter text: "); + string text = Console.ReadLine(); + service.SetText(text); + break; + + case "2": + Console.WriteLine("Current Text: " + service.GetText()); + break; + + case "3": + service.ToUpperCase(); + Console.WriteLine("Converted to UPPERCASE."); + break; + + case "4": + service.ToLowerCase(); + Console.WriteLine("Converted to lowercase."); + break; + + case "5": + Console.WriteLine("Character Count: " + service.CountCharacters()); + break; + + case "6": + Console.Write("Enter word to check: "); + string word = Console.ReadLine(); + bool contains = service.ContainsWord(word); + Console.WriteLine(contains ? "Word found." : "Word not found."); + break; + + case "7": + Console.Write("Enter word to replace: "); + string oldWord = Console.ReadLine(); + Console.Write("Enter new word: "); + string newWord = Console.ReadLine(); + service.ReplaceWord(oldWord, newWord); + Console.WriteLine("Word replaced."); + break; + + case "8": + Console.Write("Enter start index: "); + int start = int.Parse(Console.ReadLine()); + Console.Write("Enter length: "); + int length = int.Parse(Console.ReadLine()); + service.ExtractSubstring(start, length); + Console.WriteLine("Substring extracted."); + break; + + case "9": + service.TrimSpaces(); + Console.WriteLine("Spaces trimmed."); + break; + + case "10": + service.ResetText(); + Console.WriteLine("Text reset to original."); + break; + + case "11": + isRunning = false; + Console.WriteLine("Exiting program..."); + break; + + default: + Console.WriteLine("Invalid option. Try again."); + break; + } + } + } +} From 602052410f3af6ab7f6c884897ec389340d320d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Qui=C3=B1anola=20CJ?= Date: Sat, 28 Feb 2026 10:52:57 +0800 Subject: [PATCH 3/9] Add Program.cs with main entry point --- Program.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Program.cs diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..4b331ce --- /dev/null +++ b/Program.cs @@ -0,0 +1,13 @@ +using StringProcessing.Views; + +namespace StringProcessing +{ + class Program + { + static void Main(string[] args) + { + StringView view = new StringView(); + view.Run(); + } + } +} From 964c15f9e75a0af5b6ed0639318751442949b5a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Qui=C3=B1anola=20CJ?= Date: Sat, 28 Feb 2026 11:04:49 +0800 Subject: [PATCH 4/9] Delete Program.cs --- Program.cs | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 Program.cs diff --git a/Program.cs b/Program.cs deleted file mode 100644 index 4b331ce..0000000 --- a/Program.cs +++ /dev/null @@ -1,13 +0,0 @@ -using StringProcessing.Views; - -namespace StringProcessing -{ - class Program - { - static void Main(string[] args) - { - StringView view = new StringView(); - view.Run(); - } - } -} From ee4f1c2a9e814f701b080bc07e3553419d250e2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Qui=C3=B1anola=20CJ?= Date: Sat, 28 Feb 2026 11:04:58 +0800 Subject: [PATCH 5/9] Delete StringService.cs --- StringService.cs | 61 ------------------------------------------------ 1 file changed, 61 deletions(-) delete mode 100644 StringService.cs diff --git a/StringService.cs b/StringService.cs deleted file mode 100644 index f1ac2ee..0000000 --- a/StringService.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System; - -namespace StringProcessing.Services -{ - public class StringService - { - private string currentText = ""; - private string originalText = ""; - - public void SetText(string text) - { - currentText = text; - originalText = text; - } - - public string GetText() - { - return currentText; - } - - public void ToUpperCase() - { - currentText = currentText.ToUpper(); - } - - public void ToLowerCase() - { - currentText = currentText.ToLower(); - } - - public int CountCharacters() - { - return currentText.Length; - } - - public bool ContainsWord(string word) - { - return currentText.Contains(word); - } - - public void ReplaceWord(string oldWord, string newWord) - { - currentText = currentText.Replace(oldWord, newWord); - } - - public void ExtractSubstring(int startIndex, int length) - { - currentText = currentText.Substring(startIndex, length); - } - - public void TrimSpaces() - { - currentText = currentText.Trim(); - } - - public void ResetText() - { - currentText = originalText; - } - } -} From b779de4dd6786f0381ac09944dc108885dd894ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Qui=C3=B1anola=20CJ?= Date: Sat, 28 Feb 2026 11:05:07 +0800 Subject: [PATCH 6/9] Delete StringView.cs --- StringView.cs | 113 -------------------------------------------------- 1 file changed, 113 deletions(-) delete mode 100644 StringView.cs diff --git a/StringView.cs b/StringView.cs deleted file mode 100644 index bb99c71..0000000 --- a/StringView.cs +++ /dev/null @@ -1,113 +0,0 @@ -using System; -using StringProcessing.Services; - -namespace StringProcessing.Views -{ - public class StringView - { - private StringService service = new StringService(); - private bool isRunning = true; - - public void Run() - { - while (isRunning) - { - DisplayMenu(); - Console.Write("Select option: "); - string choice = Console.ReadLine(); - - HandleChoice(choice); - } - } - - private void DisplayMenu() - { - Console.WriteLine("\n----- String Processing System -----"); - Console.WriteLine("1. Enter Text"); - Console.WriteLine("2. View Current Text"); - Console.WriteLine("3. Convert to UPPERCASE"); - Console.WriteLine("4. Convert to lowercase"); - Console.WriteLine("5. Count Characters"); - Console.WriteLine("6. Check if Contains Word"); - Console.WriteLine("7. Replace Word"); - Console.WriteLine("8. Extract Substring"); - Console.WriteLine("9. Trim Spaces"); - Console.WriteLine("10. Reset Text"); - Console.WriteLine("11. Exit"); - } - - private void HandleChoice(string choice) - { - switch (choice) - { - case "1": - Console.Write("Enter text: "); - string text = Console.ReadLine(); - service.SetText(text); - break; - - case "2": - Console.WriteLine("Current Text: " + service.GetText()); - break; - - case "3": - service.ToUpperCase(); - Console.WriteLine("Converted to UPPERCASE."); - break; - - case "4": - service.ToLowerCase(); - Console.WriteLine("Converted to lowercase."); - break; - - case "5": - Console.WriteLine("Character Count: " + service.CountCharacters()); - break; - - case "6": - Console.Write("Enter word to check: "); - string word = Console.ReadLine(); - bool contains = service.ContainsWord(word); - Console.WriteLine(contains ? "Word found." : "Word not found."); - break; - - case "7": - Console.Write("Enter word to replace: "); - string oldWord = Console.ReadLine(); - Console.Write("Enter new word: "); - string newWord = Console.ReadLine(); - service.ReplaceWord(oldWord, newWord); - Console.WriteLine("Word replaced."); - break; - - case "8": - Console.Write("Enter start index: "); - int start = int.Parse(Console.ReadLine()); - Console.Write("Enter length: "); - int length = int.Parse(Console.ReadLine()); - service.ExtractSubstring(start, length); - Console.WriteLine("Substring extracted."); - break; - - case "9": - service.TrimSpaces(); - Console.WriteLine("Spaces trimmed."); - break; - - case "10": - service.ResetText(); - Console.WriteLine("Text reset to original."); - break; - - case "11": - isRunning = false; - Console.WriteLine("Exiting program..."); - break; - - default: - Console.WriteLine("Invalid option. Try again."); - break; - } - } - } -} From 80343704aad30783bfd6c988006b225e760f9d3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Qui=C3=B1anola=20CJ?= Date: Sat, 28 Feb 2026 11:05:23 +0800 Subject: [PATCH 7/9] Create Program.cs --- StringProcessingApp/Program.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 StringProcessingApp/Program.cs diff --git a/StringProcessingApp/Program.cs b/StringProcessingApp/Program.cs new file mode 100644 index 0000000..33de641 --- /dev/null +++ b/StringProcessingApp/Program.cs @@ -0,0 +1,13 @@ +using StringProcessingApp.Views; + +namespace StringProcessingApp +{ + class Program + { + static void Main(string[] args) + { + StringView view = new StringView(); + view.Run(); + } + } +} From 0dae652b1bf73156c6825da476dc21f9877b8448 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Qui=C3=B1anola=20CJ?= Date: Sat, 28 Feb 2026 11:07:03 +0800 Subject: [PATCH 8/9] Implement StringService for text manipulation --- StringProcessingApp/Services/StringService.cs | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 StringProcessingApp/Services/StringService.cs diff --git a/StringProcessingApp/Services/StringService.cs b/StringProcessingApp/Services/StringService.cs new file mode 100644 index 0000000..566a49f --- /dev/null +++ b/StringProcessingApp/Services/StringService.cs @@ -0,0 +1,61 @@ +using System; + +namespace StringProcessingApp.Services +{ + public class StringService + { + private string currentText = ""; + private string originalText = ""; + + public void SetText(string text) + { + currentText = text; + originalText = text; + } + + public string GetText() + { + return currentText; + } + + public void ToUpperCase() + { + currentText = currentText.ToUpper(); + } + + public void ToLowerCase() + { + currentText = currentText.ToLower(); + } + + public int CountCharacters() + { + return currentText.Length; + } + + public bool ContainsWord(string word) + { + return currentText.Contains(word); + } + + public void ReplaceWord(string oldWord, string newWord) + { + currentText = currentText.Replace(oldWord, newWord); + } + + public void ExtractSubstring(int startIndex, int length) + { + currentText = currentText.Substring(startIndex, length); + } + + public void TrimSpaces() + { + currentText = currentText.Trim(); + } + + public void ResetText() + { + currentText = originalText; + } + } +} From b657e3dd1d0cd80c464e450511290c27c133d4c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Qui=C3=B1anola=20CJ?= Date: Sat, 28 Feb 2026 11:10:09 +0800 Subject: [PATCH 9/9] Add StringView class for string processing functionality --- StringProcessingApp/Views/StringView.cs | 113 ++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 StringProcessingApp/Views/StringView.cs diff --git a/StringProcessingApp/Views/StringView.cs b/StringProcessingApp/Views/StringView.cs new file mode 100644 index 0000000..972e4c8 --- /dev/null +++ b/StringProcessingApp/Views/StringView.cs @@ -0,0 +1,113 @@ +using System; +using StringProcessingApp.Services; + +namespace StringProcessingApp.Views +{ + public class StringView + { + private StringService service = new StringService(); + private bool isRunning = true; + + public void Run() + { + while (isRunning) + { + DisplayMenu(); + Console.Write("Select option: "); + string choice = Console.ReadLine(); + + HandleChoice(choice); + } + } + + private void DisplayMenu() + { + Console.WriteLine("\n===== String Processing System ====="); + Console.WriteLine("1. Enter Text"); + Console.WriteLine("2. View Current Text"); + Console.WriteLine("3. Convert to UPPERCASE"); + Console.WriteLine("4. Convert to lowercase"); + Console.WriteLine("5. Count Characters"); + Console.WriteLine("6. Check if Contains Word"); + Console.WriteLine("7. Replace Word"); + Console.WriteLine("8. Extract Substring"); + Console.WriteLine("9. Trim Spaces"); + Console.WriteLine("10. Reset Text"); + Console.WriteLine("11. Exit"); + } + + private void HandleChoice(string choice) + { + switch (choice) + { + case "1": + Console.Write("Enter text: "); + string text = Console.ReadLine(); + service.SetText(text); + break; + + case "2": + Console.WriteLine("Current Text: " + service.GetText()); + break; + + case "3": + service.ToUpperCase(); + Console.WriteLine("Converted to UPPERCASE."); + break; + + case "4": + service.ToLowerCase(); + Console.WriteLine("Converted to lowercase."); + break; + + case "5": + Console.WriteLine("Character Count: " + service.CountCharacters()); + break; + + case "6": + Console.Write("Enter word to check: "); + string word = Console.ReadLine(); + bool contains = service.ContainsWord(word); + Console.WriteLine(contains ? "Word found." : "Word not found."); + break; + + case "7": + Console.Write("Enter word to replace: "); + string oldWord = Console.ReadLine(); + Console.Write("Enter new word: "); + string newWord = Console.ReadLine(); + service.ReplaceWord(oldWord, newWord); + Console.WriteLine("Word replaced."); + break; + + case "8": + Console.Write("Enter start index: "); + int start = int.Parse(Console.ReadLine()); + Console.Write("Enter length: "); + int length = int.Parse(Console.ReadLine()); + service.ExtractSubstring(start, length); + Console.WriteLine("Substring extracted."); + break; + + case "9": + service.TrimSpaces(); + Console.WriteLine("Spaces trimmed."); + break; + + case "10": + service.ResetText(); + Console.WriteLine("Text reset to original."); + break; + + case "11": + isRunning = false; + Console.WriteLine("Exiting program..."); + break; + + default: + Console.WriteLine("Invalid option. Try again."); + break; + } + } + } +}