From 0595f2d4138b7ff26be62f5cb88ef576e2b9007d Mon Sep 17 00:00:00 2001 From: Broniolaiz Date: Sat, 28 Feb 2026 10:29:38 +0800 Subject: [PATCH 1/8] Create Program.cs --- 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..d31bb61 --- /dev/null +++ b/Program.cs @@ -0,0 +1,13 @@ +using StringProcessingApp.Views; + +namespace StringProcessingSystem +{ + internal class Program + { + static void Main(string[] args) + { + StringView view = new StringView(); + view.Run(); + } + } +} From bc4465f8dd7e2b9fb97299266ec2178fc4cf720b Mon Sep 17 00:00:00 2001 From: Broniolaiz Date: Sat, 28 Feb 2026 10:32:47 +0800 Subject: [PATCH 2/8] Create StringService.cs --- Services/StringService.cs | 62 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 Services/StringService.cs diff --git a/Services/StringService.cs b/Services/StringService.cs new file mode 100644 index 0000000..030dace --- /dev/null +++ b/Services/StringService.cs @@ -0,0 +1,62 @@ +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 string ExtractSubstring(int start, int length) + { + return currentText.Substring(start, length); + } + + public void TrimSpaces() + { + currentText = currentText.Trim(); + } + + public void ResetText() + { + currentText = originalText; + } + } +} From e8fd4bba97e5ae8d9bfd64c306b0ef621a269fe4 Mon Sep 17 00:00:00 2001 From: Broniolaiz Date: Sat, 28 Feb 2026 10:34:58 +0800 Subject: [PATCH 3/8] Create StringView.cs --- Views/StringView.cs | 149 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 Views/StringView.cs diff --git a/Views/StringView.cs b/Views/StringView.cs new file mode 100644 index 0000000..d9dac73 --- /dev/null +++ b/Views/StringView.cs @@ -0,0 +1,149 @@ +using System; +using StringProcessingApp.Services; + + +namespace StringProcessingApp.Views +{ + public class StringView + { + private StringService service = new StringService(); + + public void Run() + { + bool running = true; + + while (running) + { + ShowMenu(); + + Console.Write("Choose option: "); + int choice = Convert.ToInt32(Console.ReadLine()); + + switch (choice) + { + case 1: + EnterText(); + break; + + case 2: + ViewText(); + 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("Characters: " + + service.CountCharacters()); + break; + + case 6: + CheckContains(); + break; + + case 7: + ReplaceWord(); + break; + + case 8: + ExtractSubstring(); + break; + + case 9: + service.TrimSpaces(); + Console.WriteLine("Spaces trimmed."); + break; + + case 10: + service.ResetText(); + Console.WriteLine("Text reset."); + break; + + case 11: + running = false; + break; + + default: + Console.WriteLine("Invalid option."); + break; + } + + Console.WriteLine(); + } + } + + private void ShowMenu() + { + Console.WriteLine("==== 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 EnterText() + { + Console.Write("Enter text: "); + string text = Console.ReadLine(); + service.SetText(text); + } + + private void ViewText() + { + Console.WriteLine("Current Text: " + + service.GetText()); + } + + private void CheckContains() + { + Console.Write("Enter word: "); + string word = Console.ReadLine(); + + if (service.ContainsWord(word)) + Console.WriteLine("Word found."); + else + Console.WriteLine("Word not found."); + } + + private void ReplaceWord() + { + Console.Write("Old word: "); + string oldWord = Console.ReadLine(); + + Console.Write("New word: "); + string newWord = Console.ReadLine(); + + service.ReplaceWord(oldWord, newWord); + + Console.WriteLine("Word replaced."); + } + + private void ExtractSubstring() + { + Console.Write("Start index: "); + int start = Convert.ToInt32(Console.ReadLine()); + + Console.Write("Length: "); + int length = Convert.ToInt32(Console.ReadLine()); + + string result = + service.ExtractSubstring(start, length); + + Console.WriteLine("Substring: " + result); + } + } +} From aed33cc1fa57320fcf9ac1da6b9cc58d2e0ce9c5 Mon Sep 17 00:00:00 2001 From: Broniolaiz Date: Sat, 28 Feb 2026 10:41:13 +0800 Subject: [PATCH 4/8] Delete Services/StringService.cs --- Services/StringService.cs | 62 --------------------------------------- 1 file changed, 62 deletions(-) delete mode 100644 Services/StringService.cs diff --git a/Services/StringService.cs b/Services/StringService.cs deleted file mode 100644 index 030dace..0000000 --- a/Services/StringService.cs +++ /dev/null @@ -1,62 +0,0 @@ -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 string ExtractSubstring(int start, int length) - { - return currentText.Substring(start, length); - } - - public void TrimSpaces() - { - currentText = currentText.Trim(); - } - - public void ResetText() - { - currentText = originalText; - } - } -} From 5ac0723b56eb8c47bc558e88d10776b8d6176ecb Mon Sep 17 00:00:00 2001 From: Broniolaiz Date: Sat, 28 Feb 2026 10:41:29 +0800 Subject: [PATCH 5/8] Delete Views/StringView.cs --- Views/StringView.cs | 149 -------------------------------------------- 1 file changed, 149 deletions(-) delete mode 100644 Views/StringView.cs diff --git a/Views/StringView.cs b/Views/StringView.cs deleted file mode 100644 index d9dac73..0000000 --- a/Views/StringView.cs +++ /dev/null @@ -1,149 +0,0 @@ -using System; -using StringProcessingApp.Services; - - -namespace StringProcessingApp.Views -{ - public class StringView - { - private StringService service = new StringService(); - - public void Run() - { - bool running = true; - - while (running) - { - ShowMenu(); - - Console.Write("Choose option: "); - int choice = Convert.ToInt32(Console.ReadLine()); - - switch (choice) - { - case 1: - EnterText(); - break; - - case 2: - ViewText(); - 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("Characters: " + - service.CountCharacters()); - break; - - case 6: - CheckContains(); - break; - - case 7: - ReplaceWord(); - break; - - case 8: - ExtractSubstring(); - break; - - case 9: - service.TrimSpaces(); - Console.WriteLine("Spaces trimmed."); - break; - - case 10: - service.ResetText(); - Console.WriteLine("Text reset."); - break; - - case 11: - running = false; - break; - - default: - Console.WriteLine("Invalid option."); - break; - } - - Console.WriteLine(); - } - } - - private void ShowMenu() - { - Console.WriteLine("==== 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 EnterText() - { - Console.Write("Enter text: "); - string text = Console.ReadLine(); - service.SetText(text); - } - - private void ViewText() - { - Console.WriteLine("Current Text: " + - service.GetText()); - } - - private void CheckContains() - { - Console.Write("Enter word: "); - string word = Console.ReadLine(); - - if (service.ContainsWord(word)) - Console.WriteLine("Word found."); - else - Console.WriteLine("Word not found."); - } - - private void ReplaceWord() - { - Console.Write("Old word: "); - string oldWord = Console.ReadLine(); - - Console.Write("New word: "); - string newWord = Console.ReadLine(); - - service.ReplaceWord(oldWord, newWord); - - Console.WriteLine("Word replaced."); - } - - private void ExtractSubstring() - { - Console.Write("Start index: "); - int start = Convert.ToInt32(Console.ReadLine()); - - Console.Write("Length: "); - int length = Convert.ToInt32(Console.ReadLine()); - - string result = - service.ExtractSubstring(start, length); - - Console.WriteLine("Substring: " + result); - } - } -} From 78e50bdfec5bbbff6211b645192f24d326838b20 Mon Sep 17 00:00:00 2001 From: Broniolaiz Date: Sat, 28 Feb 2026 10:44:06 +0800 Subject: [PATCH 6/8] Refactor StringService by removing comments --- 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..59728cf --- /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 string ExtractSubstring(int start, int length) + { + return currentText.Substring(start, length); + } + + public void TrimSpaces() + { + currentText = currentText.Trim(); + } + + public void ResetText() + { + currentText = originalText; + } + } +} From 85ca53c389471294dd77610a9938b0d7e1bb3f20 Mon Sep 17 00:00:00 2001 From: Broniolaiz Date: Sat, 28 Feb 2026 10:45:39 +0800 Subject: [PATCH 7/8] Remove blank line in StringView class Removed unnecessary blank line at the beginning of the StringView class. --- StringProcessingApp/Views/StringView.cs | 148 ++++++++++++++++++++++++ 1 file changed, 148 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..af59f0b --- /dev/null +++ b/StringProcessingApp/Views/StringView.cs @@ -0,0 +1,148 @@ +using System; +using StringProcessingApp.Services; + +namespace StringProcessingApp.Views +{ + public class StringView + { + private StringService service = new StringService(); + + public void Run() + { + bool running = true; + + while (running) + { + ShowMenu(); + + Console.Write("Choose option: "); + int choice = Convert.ToInt32(Console.ReadLine()); + + switch (choice) + { + case 1: + EnterText(); + break; + + case 2: + ViewText(); + 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("Characters: " + + service.CountCharacters()); + break; + + case 6: + CheckContains(); + break; + + case 7: + ReplaceWord(); + break; + + case 8: + ExtractSubstring(); + break; + + case 9: + service.TrimSpaces(); + Console.WriteLine("Spaces trimmed."); + break; + + case 10: + service.ResetText(); + Console.WriteLine("Text reset."); + break; + + case 11: + running = false; + break; + + default: + Console.WriteLine("Invalid option."); + break; + } + + Console.WriteLine(); + } + } + + private void ShowMenu() + { + Console.WriteLine("==== 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 EnterText() + { + Console.Write("Enter text: "); + string text = Console.ReadLine(); + service.SetText(text); + } + + private void ViewText() + { + Console.WriteLine("Current Text: " + + service.GetText()); + } + + private void CheckContains() + { + Console.Write("Enter word: "); + string word = Console.ReadLine(); + + if (service.ContainsWord(word)) + Console.WriteLine("Word found."); + else + Console.WriteLine("Word not found."); + } + + private void ReplaceWord() + { + Console.Write("Old word: "); + string oldWord = Console.ReadLine(); + + Console.Write("New word: "); + string newWord = Console.ReadLine(); + + service.ReplaceWord(oldWord, newWord); + + Console.WriteLine("Word replaced."); + } + + private void ExtractSubstring() + { + Console.Write("Start index: "); + int start = Convert.ToInt32(Console.ReadLine()); + + Console.Write("Length: "); + int length = Convert.ToInt32(Console.ReadLine()); + + string result = + service.ExtractSubstring(start, length); + + Console.WriteLine("Substring: " + result); + } + } +} From de2a9fd07be4c90fa65397224a53642076f86ba5 Mon Sep 17 00:00:00 2001 From: Broniolaiz Date: Sat, 28 Feb 2026 11:54:37 +0800 Subject: [PATCH 8/8] Update StringView.cs