-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringView.cs
More file actions
109 lines (99 loc) · 3.84 KB
/
StringView.cs
File metadata and controls
109 lines (99 loc) · 3.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
using System;
using StringProcessingApp.Services;
namespace StringProcessingApp.Views
{
public class StringView
{
StringService service = new StringService();
public void Start()
{
int choice = 0;
while (choice != 11)
{
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");
Console.Write("Choose: ");
choice = Convert.ToInt32(Console.ReadLine());
if (choice == 1)
{
Console.Write("Enter text: ");
string text = Console.ReadLine();
service.EnterText(text);
}
else if (choice == 2)
{
Console.WriteLine("Current Text: " + service.GetText());
}
else if (choice == 3)
{
service.MakeUpper();
Console.WriteLine("Converted to UPPERCASE.");
}
else if (choice == 4)
{
service.MakeLower();
Console.WriteLine("Converted to lowercase.");
}
else if (choice == 5)
{
Console.WriteLine("Length: " + service.GetLength());
}
else if (choice == 6)
{
Console.Write("Enter word to check: ");
string word = Console.ReadLine();
if (service.CheckContains(word))
Console.WriteLine("Word found!");
else
Console.WriteLine("Word not found.");
}
else if (choice == 7)
{
Console.Write("Word to replace: ");
string oldWord = Console.ReadLine();
Console.Write("New word: ");
string newWord = Console.ReadLine();
service.ReplaceWord(oldWord, newWord);
Console.WriteLine("Replaced successfully.");
}
else if (choice == 8)
{
Console.Write("Start index: ");
int start = Convert.ToInt32(Console.ReadLine());
Console.Write("Length: ");
int length = Convert.ToInt32(Console.ReadLine());
service.GetSubstring(start, length);
Console.WriteLine("Substring extracted.");
}
else if (choice == 9)
{
service.TrimText();
Console.WriteLine("Spaces removed.");
}
else if (choice == 10)
{
service.Reset();
Console.WriteLine("Text reset.");
}
else if (choice == 11)
{
Console.WriteLine("Goodbye!");
}
else
{
Console.WriteLine("Invalid choice.");
}
}
}
}
}