-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
139 lines (122 loc) · 2.75 KB
/
Copy pathProgram.cs
File metadata and controls
139 lines (122 loc) · 2.75 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
// See https://aka.ms/new-console-template for more information
using System;
using System.Linq;
var Todo = new List<string>();
Console.ForegroundColor = ConsoleColor.DarkBlue;
Console.WriteLine(" Hello There In Our Todo Project !");
Console.ForegroundColor = ConsoleColor.White;
bool ExitLoop = true;
while (ExitLoop)
{
Console.WriteLine("What do you want to do?");
Console.WriteLine("[S]ee all TODOs");
Console.WriteLine("[A]dd a TODO");
Console.WriteLine("[R]emove a TODO");
Console.WriteLine("[E]xit");
var UserInput = Console.ReadLine();
switch (UserInput)
{
case "e":
case "E":
ExitLoop = false;
break;
case "A":
case "a":
addCase();
break;
case "S":
case "s":
SeeTodos();
break;
case "R":
case "r":
RemoveTodos();
break;
default:
InvalidIndexMessage();
break;
}
}
void SeeTodos()
{
if (Todo.Count == 0)
{
Console.WriteLine(" No Todo To Show Yet ");
return;
}
for (int i = 0; i < Todo.Count; i++)
{
Console.WriteLine($"{i + 1}.{Todo[i]}");
}
}
void addCase()
{
string describtion;
do
{
Console.WriteLine("Add New Describiton");
describtion = Console.ReadLine();
}
while (!describtionValidition(describtion));
Console.WriteLine("The Todo Just Add Is " + describtion);
Todo.Add(describtion);
}
void RemoveTodos()
{
int index;
if (Todo.Count() == 0)
{
EmptyMessage();
return;
}
do
{
}
while (!removingmethod(out index));
RemovingConfirmaition(index - 1);
}
void RemovingConfirmaition(int index)
{
Console.WriteLine("The Todo you Remove Is : " + Todo[index]);
Todo.Remove(Todo[index]);
}
static void EmptyMessage()
{
Console.WriteLine("Should Not Be Empety");
}
static void InvalidIndexMessage()
{
Console.WriteLine("Invlaid Index You Choosen");
}
bool describtionValidition(string Description)
{
if (Description == "")
{
EmptyMessage();
return false;
}
if (Todo.Contains(Description))
{
Console.WriteLine("The description must be uniqe");
return false;
}
return true;
}
bool removingmethod(out int index)
{
Console.WriteLine("Select the index of the TODO you want to remove:");
SeeTodos();
var SelectedTodo = Console.ReadLine();
if (SelectedTodo == "")
{
index = 0;
Console.WriteLine("You should Choose Index");
return false;
}
if (int.TryParse(SelectedTodo, out index) && index >= 1 && index <= Todo.Count())
{
return true;
}
InvalidIndexMessage();
return false;
}