Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
74 lines (71 loc) · 2.39 KB

File metadata and controls

74 lines (71 loc) · 2.39 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
namespace ConsoleBasedTaskManager
{
internal class Program
{
static void Main(string[] args)
{
List<string> tasks = new List<string>();
bool exitApp = false;
do
{
AppMenu();
string? input = Console.ReadLine();
if (String.IsNullOrEmpty(input) || !int.TryParse(input, out int choice) || (choice < 1 || choice > 3))
{
Console.Clear();
Console.WriteLine("Invalid input. Please try again.");
continue;
}
switch (choice)
{
case 1:
Console.Clear();
string task = AddTask();
if (!String.IsNullOrEmpty(task))
{
tasks.Add(task);
}
break;
case 2:
Console.Clear();
if (tasks.Count > 0)
{
foreach (string t in tasks)
{
Console.WriteLine(":: " + t);
}
}
else
{
Console.WriteLine("No Tasks Found!");
}
break;
case 3:
Console.Clear();
exitApp = true;
break;
}
} while (!exitApp);
}
static void AppMenu()
{
Console.WriteLine("============================= MAIN MENU =================================");
Console.WriteLine("1. Add Task");
Console.WriteLine("2. List Tasks");
Console.WriteLine("3. Exit");
Console.Write("Select an option: ");
}
static string AddTask()
{
Console.Write("Enter Task Name (or Press Enter to Cancel): ");
string? taskName = Console.ReadLine();
if (String.IsNullOrEmpty(taskName))
{
Console.Clear();
Console.WriteLine("Task creation cancelled.");
return "";
}
return taskName;
}
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.